MCPcopy
hub / github.com/caddyserver/caddy / ServeHTTP

Method ServeHTTP

modules/caddyhttp/headers/headers.go:90–111  ·  view source on GitHub ↗
(w http.ResponseWriter, r *http.Request, next caddyhttp.Handler)

Source from the content-addressed store, hash-verified

88}
89
90func (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.
114type HeaderOps struct {

Callers 1

Calls 5

ApplyToRequestMethod · 0.80
ApplyToMethod · 0.80
ServeHTTPMethod · 0.65
ValueMethod · 0.45
HeaderMethod · 0.45

Tested by 1