summaryrefslogtreecommitdiff
path: root/modules/caddyhttp/matchers.go
diff options
context:
space:
mode:
authorJames Birtles <jameshbirtles@gmail.com>2020-06-26 22:14:47 +0100
committerGitHub <noreply@github.com>2020-06-26 15:14:47 -0600
commitddd690de4cc133bc728f765b2492ccb54f9d84ca (patch)
treee45c3554f03138efabd00b532aaad5bae521c282 /modules/caddyhttp/matchers.go
parent6004d3f779b8175d92d8eb7819ed800e8eddbff6 (diff)
caddyhttp: Support placeholders in query matcher (#3521)
Diffstat (limited to 'modules/caddyhttp/matchers.go')
-rw-r--r--modules/caddyhttp/matchers.go3
1 files changed, 3 insertions, 0 deletions
diff --git a/modules/caddyhttp/matchers.go b/modules/caddyhttp/matchers.go
index a291242..164f443 100644
--- a/modules/caddyhttp/matchers.go
+++ b/modules/caddyhttp/matchers.go
@@ -374,10 +374,13 @@ func (m *MatchQuery) UnmarshalCaddyfile(d *caddyfile.Dispenser) error {
// Match returns true if r matches m. An empty m matches an empty query string.
func (m MatchQuery) Match(r *http.Request) bool {
+ repl := r.Context().Value(caddy.ReplacerCtxKey).(*caddy.Replacer)
for param, vals := range m {
+ param = repl.ReplaceAll(param, "")
paramVal, found := r.URL.Query()[param]
if found {
for _, v := range vals {
+ v = repl.ReplaceAll(v, "")
if paramVal[0] == v || v == "*" {
return true
}