diff options
author | Matthew Holt <[email protected]> | 2019-05-10 21:07:02 -0600 |
---|---|---|
committer | Matthew Holt <[email protected]> | 2019-05-10 21:07:02 -0600 |
commit | 8ae0d6a509fd1b871457cf742369af04346933a8 (patch) | |
tree | 9a0b977e5f36acc6f06737ff34b1f21d608ada6f /modules/caddyhttp/replacer.go | |
parent | 48b5a803208548d143b7ead9b6fc9b524cd0e031 (diff) | |
download | caddy-8ae0d6a509fd1b871457cf742369af04346933a8.tar.gz caddy-8ae0d6a509fd1b871457cf742369af04346933a8.zip |
caddyhttp: Implement better HTTP matchers including regexp; add tests
Diffstat (limited to 'modules/caddyhttp/replacer.go')
-rw-r--r-- | modules/caddyhttp/replacer.go | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/modules/caddyhttp/replacer.go b/modules/caddyhttp/replacer.go index 947de092c..644cfc191 100644 --- a/modules/caddyhttp/replacer.go +++ b/modules/caddyhttp/replacer.go @@ -8,7 +8,9 @@ import ( ) // Replacer can replace values in strings based -// on a request and/or response writer. +// on a request and/or response writer. The zero +// Replacer is not valid; it must be initialized +// within this package. type Replacer struct { req *http.Request resp http.ResponseWriter @@ -75,18 +77,17 @@ func (r *Replacer) defaults() map[string]string { }(), } + // 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, ",") } - for _, cookie := range r.req.Cookies() { m["~"+cookie.Name] = cookie.Value } - for param, vals := range r.req.URL.Query() { m["?"+param] = strings.Join(vals, ",") } |