From ae687d4ba90e053cf04f0d5f2bb722c14bd01183 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=B7x?= Date: Tue, 8 Sep 2020 13:58:22 +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/Node.php | 4 ++++ HttpServer/Route/Router.php | 3 --- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/HttpServer/Route/Node.php b/HttpServer/Route/Node.php index 39a8717c..c648b2ad 100644 --- a/HttpServer/Route/Node.php +++ b/HttpServer/Route/Node.php @@ -9,6 +9,7 @@ use HttpServer\Http\Request; use Exception; use HttpServer\Application; use HttpServer\Route\Annotation\Annotation; +use Snowflake\Core\JSON; use Snowflake\Snowflake; /** @@ -415,6 +416,9 @@ class Node extends Application */ public function dispatch() { + if (empty($node->callback)) { + return JSON::to(404, 'Page not found.'); + } return call_user_func($this->callback, \request()); } diff --git a/HttpServer/Route/Router.php b/HttpServer/Route/Router.php index 09b05791..f5e63a52 100644 --- a/HttpServer/Route/Router.php +++ b/HttpServer/Route/Router.php @@ -417,9 +417,6 @@ class Router extends Application implements RouterInterface if (!($node = $this->find_path($request))) { return JSON::to(404, 'Page not found or method not allowed.'); } - if (empty($node->callback)) { - return JSON::to(404, 'Page not found.'); - } return $node->dispatch(); }