From 584eba94a4e06af9ce7efc91fb914f84d7a6a48c Mon Sep 17 00:00:00 2001 From: Francis Lavoie Date: Wed, 5 Aug 2020 15:42:29 -0400 Subject: httpcaddyfile: Allow named matchers in `route` blocks (#3632) --- caddyconfig/httpcaddyfile/directives.go | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'caddyconfig/httpcaddyfile/directives.go') diff --git a/caddyconfig/httpcaddyfile/directives.go b/caddyconfig/httpcaddyfile/directives.go index c31bdd3..e93fdd0 100644 --- a/caddyconfig/httpcaddyfile/directives.go +++ b/caddyconfig/httpcaddyfile/directives.go @@ -269,6 +269,18 @@ func (h Helper) NewBindAddresses(addrs []string) []ConfigValue { // are themselves treated as directives, from which a subroute is built // and returned. func ParseSegmentAsSubroute(h Helper) (caddyhttp.MiddlewareHandler, error) { + allResults, err := parseSegmentAsConfig(h) + if err != nil { + return nil, err + } + + return buildSubroute(allResults, h.groupCounter) +} + +// parseSegmentAsConfig parses the segment such that its subdirectives +// are themselves treated as directives, including named matcher definitions, +// and the raw Config structs are returned. +func parseSegmentAsConfig(h Helper) ([]ConfigValue, error) { var allResults []ConfigValue for h.Next() { @@ -319,7 +331,7 @@ func ParseSegmentAsSubroute(h Helper) (caddyhttp.MiddlewareHandler, error) { } } - return buildSubroute(allResults, h.groupCounter) + return allResults, nil } // ConfigValue represents a value to be added to the final -- cgit v1.2.3