@marcel91200 / caddy Mirror · read-only / commits / 348cb798
Fork 0

Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS

Mirrored from https://github.com/Slazee/caddy.git

Synced Nov 14, 05:15 UTC

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

Matthew Holt committed Mar 23, 2020 at 09:28 UTC 348cb798e26a056bd40f5ec7c0d8f440d7b6cc0b
1 file changed +11 -4
caddyconfig/httpcaddyfile/builtins.go
+11 -4
@@ -408,11 +408,18 @@ func parseRoute(h Helper) (caddyhttp.MiddlewareHandler, error) {
408 return nil, h.Errf("parsing caddyfile tokens for '%s': %v", dir, err)
409 }
410 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)
422 }
415 - sr.Routes = append(sr.Routes, handler)
423 }
424 }
425 }