diff options
author | Matthew Holt <mholt@users.noreply.github.com> | 2020-10-02 16:08:28 -0600 |
---|---|---|
committer | Matthew Holt <mholt@users.noreply.github.com> | 2020-10-02 16:08:28 -0600 |
commit | ef8a372a1ce8ed8630bbe227349783c5a74c69b2 (patch) | |
tree | 5b78d31d2d6dc1fcb99eed718f3733d43ea6d2c2 /modules/caddyhttp/map/caddyfile.go | |
parent | 0fc47e8357af5ccd6f800819722229b1a279e5b5 (diff) |
map: Bug fixes; null literal with hyphen in Caddyfile
Diffstat (limited to 'modules/caddyhttp/map/caddyfile.go')
-rw-r--r-- | modules/caddyhttp/map/caddyfile.go | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/modules/caddyhttp/map/caddyfile.go b/modules/caddyhttp/map/caddyfile.go index eb0c5ae..77d4c46 100644 --- a/modules/caddyhttp/map/caddyfile.go +++ b/modules/caddyhttp/map/caddyfile.go @@ -35,6 +35,9 @@ func init() { // If the input value is prefixed with a tilde (~), then the input will be parsed as a // regular expression. // +// The Caddyfile adapter treats outputs that are a literal hyphen (-) as a null/nil +// value. This is useful if you want to fall back to default for that particular output. +// // The number of outputs for each mapping must not be more than the number of destinations. // However, for convenience, there may be fewer outputs than destinations and any missing // outputs will be filled in implicitly. @@ -72,7 +75,11 @@ func parseCaddyfile(h httpcaddyfile.Helper) (caddyhttp.MiddlewareHandler, error) in := h.Val() var outs []interface{} for _, out := range h.RemainingArgs() { - outs = append(outs, out) + if out == "-" { + outs = append(outs, nil) + } else { + outs = append(outs, out) + } } // cannot have more outputs than destinations |