| 88 | } |
| 89 | |
| 90 | func (h Handler) ServeHTTP(w http.ResponseWriter, r *http.Request, next caddyhttp.Handler) error { |
| 91 | repl := r.Context().Value(caddy.ReplacerCtxKey).(*caddy.Replacer) |
| 92 | |
| 93 | if h.Request != nil { |
| 94 | h.Request.ApplyToRequest(r) |
| 95 | } |
| 96 | |
| 97 | if h.Response != nil { |
| 98 | if h.Response.Deferred || h.Response.Require != nil { |
| 99 | w = &responseWriterWrapper{ |
| 100 | ResponseWriterWrapper: &caddyhttp.ResponseWriterWrapper{ResponseWriter: w}, |
| 101 | replacer: repl, |
| 102 | require: h.Response.Require, |
| 103 | headerOps: h.Response.HeaderOps, |
| 104 | } |
| 105 | } else { |
| 106 | h.Response.ApplyTo(w.Header(), repl) |
| 107 | } |
| 108 | } |
| 109 | |
| 110 | return next.ServeHTTP(w, r) |
| 111 | } |
| 112 | |
| 113 | // HeaderOps defines manipulations for HTTP headers. |
| 114 | type HeaderOps struct { |