summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Holt <mholt@users.noreply.github.com>2020-03-23 09:28:29 -0600
committerMatthew Holt <mholt@users.noreply.github.com>2020-03-23 09:28:29 -0600
commit348cb798e26a056bd40f5ec7c0d8f440d7b6cc0b (patch)
treed9f8bdba61bb886c80414b38dd31b6be27555ec7
parente211491407d076a4a347fa3f0756a23888c0984d (diff)
httpcaddyfile: Allow php_fastcgi to be used in route directive
Fixes https://caddy.community/t/v2-help-to-set-up-a-yourls-instance/7260/22
-rw-r--r--caddyconfig/httpcaddyfile/builtins.go15
1 files changed, 11 insertions, 4 deletions
diff --git a/caddyconfig/httpcaddyfile/builtins.go b/caddyconfig/httpcaddyfile/builtins.go
index 9be9fb1..9fe52a7 100644
--- a/caddyconfig/httpcaddyfile/builtins.go
+++ b/caddyconfig/httpcaddyfile/builtins.go
@@ -408,11 +408,18 @@ func parseRoute(h Helper) (caddyhttp.MiddlewareHandler, error) {
return nil, h.Errf("parsing caddyfile tokens for '%s': %v", dir, err)
}
for _, result := range results {
- handler, ok := result.Value.(caddyhttp.Route)
- if !ok {
- return nil, h.Errf("%s directive returned something other than an HTTP route: %#v (only handler directives can be used in routes)", dir, result.Value)
+ switch handler := result.Value.(type) {
+ case caddyhttp.Route:
+ sr.Routes = append(sr.Routes, handler)
+ case caddyhttp.Subroute:
+ // directives which return a literal subroute instead of a route
+ // means they intend to keep those handlers together without
+ // them being reordered; we're doing that anyway since we're in
+ // the route directive, so just append its handlers
+ sr.Routes = append(sr.Routes, handler.Routes...)
+ default:
+ return nil, h.Errf("%s directive returned something other than an HTTP route or subroute: %#v (only handler directives can be used in routes)", dir, result.Value)
}
- sr.Routes = append(sr.Routes, handler)
}
}
}