From 6dfba5fda82e216cffb117a62fcefbe61cd25a34 Mon Sep 17 00:00:00 2001 From: Matthew Holt Date: Mon, 8 Jul 2019 16:46:55 -0600 Subject: Add path components to HTTP replacer --- modules/caddyhttp/replacer.go | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'modules/caddyhttp/replacer.go') diff --git a/modules/caddyhttp/replacer.go b/modules/caddyhttp/replacer.go index 11f3bdb..57bc880 100644 --- a/modules/caddyhttp/replacer.go +++ b/modules/caddyhttp/replacer.go @@ -79,6 +79,12 @@ func addHTTPVarsToReplacer(repl caddy.Replacer, req *http.Request, w http.Respon key := fmt.Sprintf("http.request.host.labels.%d", len(hostLabels)-i-1) m[key] = label } + + pathParts := strings.Split(req.URL.Path, "/") + for i, label := range pathParts { + key := fmt.Sprintf("http.request.uri.path.%d", i) + m[key] = label + } } if w != nil { -- cgit v1.2.3