From ef8a372a1ce8ed8630bbe227349783c5a74c69b2 Mon Sep 17 00:00:00 2001 From: Matthew Holt Date: Fri, 2 Oct 2020 16:08:28 -0600 Subject: map: Bug fixes; null literal with hyphen in Caddyfile --- modules/caddyhttp/map/caddyfile.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'modules/caddyhttp/map/caddyfile.go') 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 -- cgit v1.2.3