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(); }