diff options
author | Matthew Holt <mholt@users.noreply.github.com> | 2020-10-02 15:23:52 -0600 |
---|---|---|
committer | Matthew Holt <mholt@users.noreply.github.com> | 2020-10-02 15:23:52 -0600 |
commit | 0fc47e8357af5ccd6f800819722229b1a279e5b5 (patch) | |
tree | c3b8e2fd7b9232a81ae05e545b32309d4b048a4b /modules/caddyhttp/map/caddyfile.go | |
parent | 25d2b4bf2927bf69ddce582d33339ef7d13cb6bf (diff) |
map: Apply default if mapped output is nil
Diffstat (limited to 'modules/caddyhttp/map/caddyfile.go')
-rw-r--r-- | modules/caddyhttp/map/caddyfile.go | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/modules/caddyhttp/map/caddyfile.go b/modules/caddyhttp/map/caddyfile.go index 67c148b..eb0c5ae 100644 --- a/modules/caddyhttp/map/caddyfile.go +++ b/modules/caddyhttp/map/caddyfile.go @@ -70,7 +70,10 @@ func parseCaddyfile(h httpcaddyfile.Helper) (caddyhttp.MiddlewareHandler, error) // every other line maps one input to one or more outputs in := h.Val() - outs := h.RemainingArgs() + var outs []interface{} + for _, out := range h.RemainingArgs() { + outs = append(outs, out) + } // cannot have more outputs than destinations if len(outs) > len(handler.Destinations) { @@ -78,9 +81,9 @@ func parseCaddyfile(h httpcaddyfile.Helper) (caddyhttp.MiddlewareHandler, error) } // for convenience, can have fewer outputs than destinations, but the - // underlying handler won't accept that, so we fill in empty values + // underlying handler won't accept that, so we fill in nil values for len(outs) < len(handler.Destinations) { - outs = append(outs, "") + outs = append(outs, nil) } // create the mapping |