From ff5b4639d597203f8aec43e5eae8fe3774976d32 Mon Sep 17 00:00:00 2001 From: Matthew Holt Date: Thu, 16 May 2019 11:46:17 -0600 Subject: Some minor updates, and get rid of OnLoad/OnUnload --- modules/caddyhttp/replacer.go | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'modules/caddyhttp/replacer.go') 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, ",") } } -- cgit v1.2.3