diff options
author | Matthew Holt <mholt@users.noreply.github.com> | 2019-05-16 11:46:17 -0600 |
---|---|---|
committer | Matthew Holt <mholt@users.noreply.github.com> | 2019-05-16 11:46:17 -0600 |
commit | ff5b4639d597203f8aec43e5eae8fe3774976d32 (patch) | |
tree | fa7f9d24494f61232c87efd6b68ee7f8909ffb00 /modules/caddyhttp/replacer.go | |
parent | f9d93ead4ef6e099ba7e00318dce6509b0f1eda4 (diff) |
Some minor updates, and get rid of OnLoad/OnUnload
Diffstat (limited to 'modules/caddyhttp/replacer.go')
-rw-r--r-- | modules/caddyhttp/replacer.go | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/modules/caddyhttp/replacer.go b/modules/caddyhttp/replacer.go index 1fd3428..e7aa250 100644 --- a/modules/caddyhttp/replacer.go +++ b/modules/caddyhttp/replacer.go @@ -93,19 +93,20 @@ func (r *Replacer) defaults() map[string]string { m["request.uri"] = r.req.URL.RequestURI() m["request.uri.path"] = r.req.URL.Path - // TODO: why should header fields, cookies, and query params get special treatment like this? - // maybe they should be scoped by words like "request.header." just like everything else. for field, vals := range r.req.Header { - m[">"+strings.ToLower(field)] = strings.Join(vals, ",") - } - for field, vals := range r.resp.Header() { - m["<"+strings.ToLower(field)] = strings.Join(vals, ",") + m["request.header."+strings.ToLower(field)] = strings.Join(vals, ",") } for _, cookie := range r.req.Cookies() { - m["~"+cookie.Name] = cookie.Value + m["request.cookie."+cookie.Name] = cookie.Value } for param, vals := range r.req.URL.Query() { - m["?"+param] = strings.Join(vals, ",") + m["request.uri.query."+param] = strings.Join(vals, ",") + } + } + + if r.resp != nil { + for field, vals := range r.resp.Header() { + m["response.header."+strings.ToLower(field)] = strings.Join(vals, ",") } } |