MCPcopy Index your code
hub / github.com/php/frankenphp / prependWorkerRoutes

Function prependWorkerRoutes

caddy/module.go:631–676  ·  view source on GitHub ↗

workers can also match a path without being in the public directory in this case we need to prepend the worker routes to the existing routes

(routes caddyhttp.RouteList, h httpcaddyfile.Helper, f FrankenPHPModule, fsrv caddy.Module, disableFsrv bool)

Source from the content-addressed store, hash-verified

629// workers can also match a path without being in the public directory
630// in this case we need to prepend the worker routes to the existing routes
631func prependWorkerRoutes(routes caddyhttp.RouteList, h httpcaddyfile.Helper, f FrankenPHPModule, fsrv caddy.Module, disableFsrv bool) caddyhttp.RouteList {
632 var allWorkerMatches caddyhttp.MatchPath
633 for _, w := range f.Workers {
634 for _, path := range w.MatchPath {
635 allWorkerMatches = append(allWorkerMatches, path)
636 }
637 }
638
639 if len(allWorkerMatches) == 0 {
640 return routes
641 }
642
643 // if there are match patterns, we need to check for files beforehand
644 if !disableFsrv {
645 routes = append(routes, caddyhttp.Route{
646 MatcherSetsRaw: []caddy.ModuleMap{
647 {
648 "file": h.JSON(fileserver.MatchFile{
649 TryFiles: []string{"{http.request.uri.path}"},
650 Root: f.Root,
651 }),
652 "not": h.JSON(caddyhttp.MatchNot{
653 MatcherSetsRaw: []caddy.ModuleMap{
654 {"path": h.JSON(caddyhttp.MatchPath{"*.php"})},
655 },
656 }),
657 },
658 },
659 HandlersRaw: []json.RawMessage{
660 caddyconfig.JSONModuleObject(fsrv, "handler", "file_server", nil),
661 },
662 })
663 }
664
665 // forward matching routes to the PHP handler
666 routes = append(routes, caddyhttp.Route{
667 MatcherSetsRaw: []caddy.ModuleMap{
668 {"path": h.JSON(allWorkerMatches)},
669 },
670 HandlersRaw: []json.RawMessage{
671 caddyconfig.JSONModuleObject(f, "handler", "php", nil),
672 },
673 })
674
675 return routes
676}
677
678// Interface guards
679var (

Callers 1

parsePhpServerFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected