summaryrefslogtreecommitdiff
path: root/modules/caddyhttp/matchers.go
diff options
context:
space:
mode:
authorPascal <pascalgn@users.noreply.github.com>2019-10-14 19:29:36 +0200
committerMatt Holt <mholt@users.noreply.github.com>2019-10-14 11:29:36 -0600
commitbc738991b6234bf334855e1396919e79ef9791b8 (patch)
tree62777f65ca331cf5125708f7200d381585e74ee3 /modules/caddyhttp/matchers.go
parentfcd8869f51b78f260e3c3aed53d7d87c2051ffe9 (diff)
caddyhttp: Support placeholders in MatchHost (#2810)
* Replace global placeholders in host matcher * caddyhttp: Fix panic on MatchHost tests
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 7c35a39..23b13dd 100644
--- a/modules/caddyhttp/matchers.go
+++ b/modules/caddyhttp/matchers.go
@@ -118,8 +118,11 @@ func (m MatchHost) Match(r *http.Request) bool {
reqHost = strings.TrimSuffix(reqHost, "]")
}
+ repl := r.Context().Value(caddy.ReplacerCtxKey).(caddy.Replacer)
+
outer:
for _, host := range m {
+ host = repl.ReplaceAll(host, "")
if strings.Contains(host, "*") {
patternParts := strings.Split(host, ".")
incomingParts := strings.Split(reqHost, ".")