diff --git a/src/Server/Http/Listener/HttpRouteInit.php b/src/Server/Http/Listener/HttpRouteInit.php index be7030514..07115575d 100644 --- a/src/Server/Http/Listener/HttpRouteInit.php +++ b/src/Server/Http/Listener/HttpRouteInit.php @@ -54,7 +54,6 @@ protected function parseAnnotations(): void $context['server'] = $server; /** @var HttpRoute $route */ $route = $server->getBean('HttpRoute'); - $autoEndSlash = $route->getAutoEndSlash(); foreach ($controllerParser->getByServer($name) as $className => $classItem) { /** @var \Imi\Server\Http\Route\Annotation\Controller $classAnnotation */ @@ -173,6 +172,12 @@ protected function parseAnnotations(): void 'extractData' => $extractData, ]; $route->addRuleAnnotation($routeItem, $routeCallable, $options); + if ($routeItem->autoEndSlash && !str_ends_with($routeItem->url, '/')) + { + $routeItem = clone $routeItem; + $routeItem->url .= '/'; + $route->addRuleAnnotation($routeItem, $routeCallable, $options); + } } } }