diff options
author | Will Norris <will@willnorris.com> | 2022-09-28 12:38:20 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-09-28 13:38:20 -0600 |
commit | 61822f129b9edbbc1ed2fd068d8e5ba919b5881d (patch) | |
tree | eb68fb6691feaaefdc5793b6d5e0406865bcb3f7 /modules/caddyhttp/map/map_test.go | |
parent | e3e8aabbcf65d37516bb97f9dc0f77df52f8cf55 (diff) |
caddyhttp: replace placeholders in map defaults (#5081)
This updates the map directive to replace placeholders in default values
in the same way as matched values.
Diffstat (limited to 'modules/caddyhttp/map/map_test.go')
-rw-r--r-- | modules/caddyhttp/map/map_test.go | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/modules/caddyhttp/map/map_test.go b/modules/caddyhttp/map/map_test.go index fe233bf..3ff5e71 100644 --- a/modules/caddyhttp/map/map_test.go +++ b/modules/caddyhttp/map/map_test.go @@ -98,6 +98,28 @@ func TestHandler(t *testing.T) { "output": "testing", }, }, + { + reqURI: "/foo", + handler: Handler{ + Source: "{http.request.uri.path}", + Destinations: []string{"{output}"}, + Defaults: []string{"default"}, + }, + expect: map[string]any{ + "output": "default", + }, + }, + { + reqURI: "/foo", + handler: Handler{ + Source: "{http.request.uri.path}", + Destinations: []string{"{output}"}, + Defaults: []string{"{testvar}"}, + }, + expect: map[string]any{ + "output": "testing", + }, + }, } { if err := tc.handler.Provision(caddy.Context{}); err != nil { t.Fatalf("Test %d: Provisioning handler: %v", i, err) |