From f185c9a2362e7d9777b283a035e31b341163e2c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=B7x?= Date: Sat, 20 Feb 2021 15:59:42 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- HttpServer/Route/Router.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/HttpServer/Route/Router.php b/HttpServer/Route/Router.php index 827250df..f02a7992 100644 --- a/HttpServer/Route/Router.php +++ b/HttpServer/Route/Router.php @@ -487,6 +487,7 @@ class Router extends Application implements RouterInterface * @param $exception * @return mixed * @throws ComponentException + * @throws Exception */ private function exception($exception): mixed { @@ -498,15 +499,22 @@ class Router extends Application implements RouterInterface * @param Request $request * @return Node|null 树干搜索 * 树干搜索 + * @throws ConfigException */ private function find_path(Request $request): ?Node { $method = $request->getMethod(); + $uri = $request->headers->get('request_uri', '/'); + + $context = Config::get('router', false, ROUTER_HASH); + if ($context === ROUTER_TREE) { + return $this->Branch_search($request); + } + if (!isset($this->nodes[$method])) { return null; } $methods = $this->nodes[$method]; - $uri = $request->headers->get('request_uri', '/'); if (isset($methods[$uri])) { return $methods[$uri]; }