From bc738991b6234bf334855e1396919e79ef9791b8 Mon Sep 17 00:00:00 2001 From: Pascal Date: Mon, 14 Oct 2019 19:29:36 +0200 Subject: caddyhttp: Support placeholders in MatchHost (#2810) * Replace global placeholders in host matcher * caddyhttp: Fix panic on MatchHost tests --- modules/caddyhttp/matchers.go | 3 +++ 1 file changed, 3 insertions(+) (limited to 'modules/caddyhttp/matchers.go') 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, ".") -- cgit v1.2.3