diff options
author | Francis Lavoie <lavofr@gmail.com> | 2020-05-11 18:50:49 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-11 16:50:49 -0600 |
commit | ea7e4b4024f34fd53f8b8f7b5effb353b36cf8e8 (patch) | |
tree | 2bbf0f787eaef2e9e5f00279f0f7185bb0680a93 /caddytest | |
parent | ef6e53bb5f521e4d400849b79bc72e89fe2a7484 (diff) |
httpcaddyfile: Shorthands for parameterized placeholders (#3305)
* httpcaddyfile: Add shorthands for parameterized placeholders
httpcaddyfile: Now with regexp instead
httpcaddyfile: Allow dashes, gofmt
httpcaddyfile: Compile regexp only once
httpcaddyfile: Cleanup struct
httpcaddyfile: Optimize the replacers, pull out of the loop
httpcaddyfile: Add `{port}` shorthand
* httpcaddyfile: Switch `r.` to `re.`
Diffstat (limited to 'caddytest')
-rw-r--r-- | caddytest/integration/caddyfile_adapt_test.go | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/caddytest/integration/caddyfile_adapt_test.go b/caddytest/integration/caddyfile_adapt_test.go index 98c81da..280e22e 100644 --- a/caddytest/integration/caddyfile_adapt_test.go +++ b/caddytest/integration/caddyfile_adapt_test.go @@ -539,3 +539,49 @@ func TestLogRollDays(t *testing.T) { } }`) } + +func TestShorthandParameterizedPlaceholders(t *testing.T) { + caddytest.AssertAdapt(t, ` + localhost:80 + respond * "{header.content-type} {labels.0} {query.p} {path.0} {re.name.0}" + `, "caddyfile", `{ + "apps": { + "http": { + "servers": { + "srv0": { + "listen": [ + ":80" + ], + "routes": [ + { + "match": [ + { + "host": [ + "localhost" + ] + } + ], + "handle": [ + { + "handler": "subroute", + "routes": [ + { + "handle": [ + { + "body": "{http.request.header.content-type} {http.request.host.labels.0} {http.request.uri.query.p} {http.request.uri.path.0} {http.regexp.name.0}", + "handler": "static_response" + } + ] + } + ] + } + ], + "terminal": true + } + ] + } + } + } + } +}`) +} |