diff options
author | Matthew Holt <mholt@users.noreply.github.com> | 2019-05-20 10:59:20 -0600 |
---|---|---|
committer | Matthew Holt <mholt@users.noreply.github.com> | 2019-05-20 10:59:20 -0600 |
commit | fec7fa8bfda713e8042b9bbf9a480c7792b78c41 (patch) | |
tree | 53d86ab50ef7d15e9688c81b6618024c4243c98d /modules/caddyhttp/staticresp.go | |
parent | 1a20fe330ecc39e8b98b5669b836f3b1b185f622 (diff) |
Implement most of static file server; refactor and improve Replacer
Diffstat (limited to 'modules/caddyhttp/staticresp.go')
-rw-r--r-- | modules/caddyhttp/staticresp.go | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/modules/caddyhttp/staticresp.go b/modules/caddyhttp/staticresp.go index 506689a..69ec45b 100644 --- a/modules/caddyhttp/staticresp.go +++ b/modules/caddyhttp/staticresp.go @@ -23,16 +23,16 @@ type Static struct { } func (s Static) ServeHTTP(w http.ResponseWriter, r *http.Request) error { - repl := r.Context().Value(ReplacerCtxKey).(*Replacer) + repl := r.Context().Value(caddy2.ReplacerCtxKey).(caddy2.Replacer) // close the connection after responding r.Close = s.Close // set all headers, with replacements for field, vals := range s.Headers { - field = repl.Replace(field, "") + field = repl.ReplaceAll(field, "") for i := range vals { - vals[i] = repl.Replace(vals[i], "") + vals[i] = repl.ReplaceAll(vals[i], "") } w.Header()[field] = vals } @@ -46,7 +46,7 @@ func (s Static) ServeHTTP(w http.ResponseWriter, r *http.Request) error { // write the response body, with replacements if s.Body != "" { - fmt.Fprint(w, repl.Replace(s.Body, "")) + fmt.Fprint(w, repl.ReplaceAll(s.Body, "")) } return nil |