diff --git a/src/ApiRoute.php b/src/ApiRoute.php index bab04cc..61585a9 100644 --- a/src/ApiRoute.php +++ b/src/ApiRoute.php @@ -53,6 +53,7 @@ class ApiRoute implements Bootstrap { const TAG_GROUP = '#group'; + const TAG_ROOT = '#root'; /** * @var RouteCollector|null @@ -221,7 +222,13 @@ public static function route(array|string $httpMethod, string $route, Closure $h 'handler' => $handler ]; } - self::middleware(self::getMiddlewareTag($handler), self::$_groupPrefix !== null ? self::getMiddlewares('#group') : $middlewares, $methods); + self::middleware( + self::getMiddlewareTag($handler), + self::getMiddlewares(self::TAG_ROOT) + (self::$_groupPrefix !== null ? + self::getMiddlewares(self::TAG_GROUP) : + $middlewares), + $methods + ); self::$_collector->addRoute($methods, $route, $handler); } diff --git a/src/ApiServer.php b/src/ApiServer.php index 2ffa749..5ed9406 100644 --- a/src/ApiServer.php +++ b/src/ApiServer.php @@ -89,7 +89,7 @@ public function onWorkerStart(Worker $worker): void } } if ($mid) { - ApiRoute::middleware(ApiRoute::TAG_GROUP, $mid); + ApiRoute::middleware(ApiRoute::TAG_ROOT, $mid); } } }