From 0354949c0bfa31b4a9728deb48007f0aadbb546a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=B7x?= Date: Tue, 20 Apr 2021 15:11:00 +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 | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/HttpServer/Route/Node.php b/HttpServer/Route/Node.php index 7491fcdc..a91d5f16 100644 --- a/HttpServer/Route/Node.php +++ b/HttpServer/Route/Node.php @@ -14,6 +14,7 @@ use Closure; use Exception; use HttpServer\Abstracts\HttpService; use HttpServer\Controller; +use HttpServer\Http\Context; use HttpServer\Http\Request; use HttpServer\HttpFilter; use JetBrains\PhpStorm\Pure; @@ -125,7 +126,11 @@ class Node extends HttpService public function createDispatch(): Closure { return function () { - return call_user_func($this->handler, ...func_get_args()); + $dispatchParam = Context::getContext('dispatch-param'); + if (empty($dispatchParam)) { + $dispatchParam = [\request()]; + } + return call_user_func($this->handler, ...$dispatchParam); }; } @@ -513,6 +518,7 @@ class Node extends HttpService */ public function dispatch(): mixed { + Context::setContext('dispatch-param', func_get_args()); if (empty($this->callback)) { return Json::to(404, $this->errorMsg()); }