summaryrefslogtreecommitdiff
path: root/caddyconfig/httpcaddyfile/directives.go
diff options
context:
space:
mode:
authorFrancis Lavoie <lavofr@gmail.com>2020-08-05 15:42:29 -0400
committerGitHub <noreply@github.com>2020-08-05 13:42:29 -0600
commit584eba94a4e06af9ce7efc91fb914f84d7a6a48c (patch)
treed01bd6c67e2bf9e8d895982a4b6f246b146b45bf /caddyconfig/httpcaddyfile/directives.go
parent904f149e5b2f0ae9eff09dacb4f1ec41c4a76298 (diff)
httpcaddyfile: Allow named matchers in `route` blocks (#3632)
Diffstat (limited to 'caddyconfig/httpcaddyfile/directives.go')
-rw-r--r--caddyconfig/httpcaddyfile/directives.go14
1 files changed, 13 insertions, 1 deletions
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