From 2bb66237fabbbf2733f3869b1579203f10f15984 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Dunglas?= Date: Thu, 5 Nov 2026 13:06:29 +0100 Subject: [PATCH] refactor(caddy): detect named routes with Helper.IsNamedRoute() Caddy 2.11.9 tells a directive whether it's parsed inside a named route (caddyserver/caddy#8354). Use it instead of inferring it from the named_routes option, which relied on the order Caddy adapts blocks in. --- caddy/module.go | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/caddy/module.go b/caddy/module.go index 21293cf2f1..cf7fa7a63f 100644 --- a/caddy/module.go +++ b/caddy/module.go @@ -331,18 +331,13 @@ const namedRouteServerIndexBase = 1 << 20 func (f *FrankenPHPModule) assignServerIndex(h httpcaddyfile.Helper) { counter, ok := h.State["php_server_count"].(int) - if !ok && inNamedRoute(h) { + if !ok && h.IsNamedRoute() { counter = namedRouteServerIndexBase } f.ServerIndex = counter + 1 h.State["php_server_count"] = counter + 1 } -// inNamedRoute relies on Caddy setting the named_routes option only once all named routes are adapted -func inNamedRoute(h httpcaddyfile.Helper) bool { - return h.Option("named_routes") == nil -} - // parseCaddyfile unmarshals tokens from h into a new Middleware. func parseCaddyfile(h httpcaddyfile.Helper) (caddyhttp.MiddlewareHandler, error) { m := &FrankenPHPModule{}