This commit is contained in:
2021-08-03 11:55:12 +08:00
parent ffd685d8b4
commit e5d97e5a29
+3 -3
View File
@@ -120,7 +120,7 @@ class Router extends HttpService implements RouterInterface
if ($handler instanceof Closure) { if ($handler instanceof Closure) {
$handler = Closure::bind($handler, di(Controller::class)); $handler = Closure::bind($handler, di(Controller::class));
} }
return $this->hash($path, $handler, $method); return $this->tree($path, $handler, $method);
} }
@@ -278,7 +278,7 @@ class Router extends HttpService implements RouterInterface
public function any($route, $handler): Any public function any($route, $handler): Any
{ {
$nodes = []; $nodes = [];
foreach (['GET', 'POST', 'OPTIONS', 'PUT', 'DELETE', 'HEAD'] as $method) { foreach ($this->methods as $method) {
$nodes[] = $this->addRoute($route, $handler, $method); $nodes[] = $this->addRoute($route, $handler, $method);
} }
return new Any($nodes); return new Any($nodes);
@@ -515,7 +515,7 @@ class Router extends HttpService implements RouterInterface
*/ */
public function dispatch(Request $request): void public function dispatch(Request $request): void
{ {
$node = $this->find_path($request); $node = $this->Branch_search($request);
if (!($node instanceof Node)) { if (!($node instanceof Node)) {
$this->response->setFormat(Response::HTML); $this->response->setFormat(Response::HTML);
$this->response->send('<h1 style="text-align: center;">404</h1>'); $this->response->send('<h1 style="text-align: center;">404</h1>');