diff --git a/HttpServer/Route/Router.php b/HttpServer/Route/Router.php index bac671d5..cb162c2d 100644 --- a/HttpServer/Route/Router.php +++ b/HttpServer/Route/Router.php @@ -113,15 +113,12 @@ class Router extends HttpService implements RouterInterface */ public function addRoute($path, $handler, string $method = 'any'): ?Node { - $method = strtolower($method); if (!isset(static::$nodes[$method])) { static::$nodes[$method] = []; } - if ($handler instanceof Closure) { - $handler = Closure::bind($handler, new Controller()); + $handler = Closure::bind($handler, di(Controller::class)); } - return $this->hash($path, $handler, $method); }