This commit is contained in:
2021-07-27 19:14:46 +08:00
parent 59498620a0
commit 3c15820e78
+1 -4
View File
@@ -113,15 +113,12 @@ class Router extends HttpService implements RouterInterface
*/ */
public function addRoute($path, $handler, string $method = 'any'): ?Node public function addRoute($path, $handler, string $method = 'any'): ?Node
{ {
$method = strtolower($method);
if (!isset(static::$nodes[$method])) { if (!isset(static::$nodes[$method])) {
static::$nodes[$method] = []; static::$nodes[$method] = [];
} }
if ($handler instanceof Closure) { if ($handler instanceof Closure) {
$handler = Closure::bind($handler, new Controller()); $handler = Closure::bind($handler, di(Controller::class));
} }
return $this->hash($path, $handler, $method); return $this->hash($path, $handler, $method);
} }