From fec7fa8bfda713e8042b9bbf9a480c7792b78c41 Mon Sep 17 00:00:00 2001 From: Matthew Holt Date: Mon, 20 May 2019 10:59:20 -0600 Subject: Implement most of static file server; refactor and improve Replacer --- modules/caddyhttp/staticresp.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'modules/caddyhttp/staticresp.go') 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 -- cgit v1.2.3