mirror of
https://github.com/caddyserver/caddy.git
synced 2026-08-03 22:33:28 +00:00
httpserver: give each req context a Replacer that preserves custom values (#1937)
This allows custom replacements to be defined in a way that propagates throughout all plugins.
This commit is contained in:
parent
169ab3acda
commit
9a22cda15d
3 changed files with 31 additions and 12 deletions
|
|
@ -356,6 +356,12 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||
c := context.WithValue(r.Context(), OriginalURLCtxKey, urlCopy)
|
||||
r = r.WithContext(c)
|
||||
|
||||
// Setup a replacer for the request that keeps track of placeholder
|
||||
// values across plugins.
|
||||
replacer := NewReplacer(r, nil, "")
|
||||
c = context.WithValue(r.Context(), ReplacerCtxKey, replacer)
|
||||
r = r.WithContext(c)
|
||||
|
||||
w.Header().Set("Server", caddy.AppName)
|
||||
|
||||
status, _ := s.serveHTTP(w, r)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue