Skip to content

Commit 348cb79

Browse files
committed
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
1 parent e211491 commit 348cb79

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

caddyconfig/httpcaddyfile/builtins.go

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -408,11 +408,18 @@ func parseRoute(h Helper) (caddyhttp.MiddlewareHandler, error) {
408408
return nil, h.Errf("parsing caddyfile tokens for '%s': %v", dir, err)
409409
}
410410
for _, result := range results {
411-
handler, ok := result.Value.(caddyhttp.Route)
412-
if !ok {
413-
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)
411+
switch handler := result.Value.(type) {
412+
case caddyhttp.Route:
413+
sr.Routes = append(sr.Routes, handler)
414+
case caddyhttp.Subroute:
415+
// directives which return a literal subroute instead of a route
416+
// means they intend to keep those handlers together without
417+
// them being reordered; we're doing that anyway since we're in
418+
// the route directive, so just append its handlers
419+
sr.Routes = append(sr.Routes, handler.Routes...)
420+
default:
421+
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)
414422
}
415-
sr.Routes = append(sr.Routes, handler)
416423
}
417424
}
418425
}

0 commit comments

Comments
 (0)