From a33e4b542689cbe7ac711e3cfde1d2a30c0156ae Mon Sep 17 00:00:00 2001 From: Mohammed Al Sahaf Date: Sat, 26 Sep 2020 02:50:26 +0300 Subject: caddyfile: Add support for `vars` and `vars_regexp` matchers (#3730) * caddyfile: support vars and vars_regexp matchers in the caddyfile * caddyfile: matchers: Brian Kernighan said printf is good debugging tool but didn't say keep them around --- .../integration/caddyfile_adapt/matcher_syntax.txt | 59 ++++++++++++++++++++++ 1 file changed, 59 insertions(+) (limited to 'caddytest') diff --git a/caddytest/integration/caddyfile_adapt/matcher_syntax.txt b/caddytest/integration/caddyfile_adapt/matcher_syntax.txt index 8cabc58..53ec023 100644 --- a/caddytest/integration/caddyfile_adapt/matcher_syntax.txt +++ b/caddytest/integration/caddyfile_adapt/matcher_syntax.txt @@ -9,6 +9,15 @@ @matcher3 not method PUT respond @matcher3 "not put" + + @matcher4 vars "{http.request.uri}" "/vars-matcher" + respond @matcher4 "from vars matcher" + + @matcher5 vars_regexp static "{http.request.uri}" `\.([a-f0-9]{6})\.(css|js)$` + respond @matcher5 "from vars_regexp matcher with name" + + @matcher6 vars_regexp "{http.request.uri}" `\.([a-f0-9]{6})\.(css|js)$` + respond @matcher6 "from vars_regexp matcher without name" } ---------- { @@ -68,6 +77,56 @@ "handler": "static_response" } ] + }, + { + "match": [ + { + "vars": { + "{http.request.uri}": "/vars-matcher" + } + } + ], + "handle": [ + { + "body": "from vars matcher", + "handler": "static_response" + } + ] + }, + { + "match": [ + { + "vars_regexp": { + "{http.request.uri}": { + "name": "static", + "pattern": "\\.([a-f0-9]{6})\\.(css|js)$" + } + } + } + ], + "handle": [ + { + "body": "from vars_regexp matcher with name", + "handler": "static_response" + } + ] + }, + { + "match": [ + { + "vars_regexp": { + "{http.request.uri}": { + "pattern": "\\.([a-f0-9]{6})\\.(css|js)$" + } + } + } + ], + "handle": [ + { + "body": "from vars_regexp matcher without name", + "handler": "static_response" + } + ] } ] } -- cgit v1.2.3