aboutsummaryrefslogtreecommitdiffhomepage
path: root/modules/caddyhttp/replacer.go
diff options
context:
space:
mode:
authorFrancis Lavoie <[email protected]>2024-11-28 12:38:46 -0500
committerFrancis Lavoie <[email protected]>2024-12-01 17:21:44 -0500
commitd5237a62c72dc5a57104b6d1d94297e0a9ad23f9 (patch)
treeac2be19ee8cff6e8cbb3f7d5a9d1b6772413e1d0 /modules/caddyhttp/replacer.go
parent68edb1acd1860552542314cdaec1094a3cb7e33a (diff)
downloadcaddy-prefixed-query.tar.gz
caddy-prefixed-query.zip
Use orig_uri instead for the redirect, shorter Caddyfile shortcutprefixed-query
Diffstat (limited to 'modules/caddyhttp/replacer.go')
-rw-r--r--modules/caddyhttp/replacer.go6
1 files changed, 6 insertions, 0 deletions
diff --git a/modules/caddyhttp/replacer.go b/modules/caddyhttp/replacer.go
index bb2623771..776aa6294 100644
--- a/modules/caddyhttp/replacer.go
+++ b/modules/caddyhttp/replacer.go
@@ -244,6 +244,12 @@ func addHTTPVarsToReplacer(repl *caddy.Replacer, req *http.Request, w http.Respo
case "http.request.orig_uri.query":
or, _ := req.Context().Value(OriginalRequestCtxKey).(http.Request)
return or.URL.RawQuery, true
+ case "http.request.orig_uri.prefixed_query":
+ or, _ := req.Context().Value(OriginalRequestCtxKey).(http.Request)
+ if or.URL.RawQuery == "" {
+ return "", true
+ }
+ return "?" + or.URL.RawQuery, true
}
// remote IP range/prefix (e.g. keep top 24 bits of 1.2.3.4 => "1.2.3.0/24")