From 52886be6aad5ff614e44f93586bf7a21ad88e988 Mon Sep 17 00:00:00 2001 From: "as2252258@163.com" Date: Wed, 21 Apr 2021 01:40:00 +0800 Subject: [PATCH] modify --- HttpServer/Route/Dispatch/Dispatch.php | 6 +++++- HttpServer/Route/Node.php | 7 +++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/HttpServer/Route/Dispatch/Dispatch.php b/HttpServer/Route/Dispatch/Dispatch.php index 528c8354..db51501d 100644 --- a/HttpServer/Route/Dispatch/Dispatch.php +++ b/HttpServer/Route/Dispatch/Dispatch.php @@ -36,7 +36,11 @@ class Dispatch { $class = new static(); $class->handler = $handler; - $class->request = $request; + $dispatchParam = Context::getContext('dispatch-param'); + if (empty($dispatchParam)) { + $dispatchParam = [\request()]; + } + $class->request = $dispatchParam; if ($handler instanceof Closure) { $class->bind(); } diff --git a/HttpServer/Route/Node.php b/HttpServer/Route/Node.php index f08ee4eb..0f24647d 100644 --- a/HttpServer/Route/Node.php +++ b/HttpServer/Route/Node.php @@ -17,6 +17,7 @@ use HttpServer\Controller; use HttpServer\Http\Context; use HttpServer\Http\Request; use HttpServer\HttpFilter; +use HttpServer\Route\Dispatch\Dispatch; use JetBrains\PhpStorm\Pure; use Snowflake\Core\Json; use Snowflake\Snowflake; @@ -126,10 +127,8 @@ class Node extends HttpService public function createDispatch(): Closure { return function () { - $dispatchParam = Context::getContext('dispatch-param'); - if (empty($dispatchParam)) { - $dispatchParam = [\request()]; - } + return Dispatch::create($this->handler,\request())->dispatch(); + return call_user_func($this->handler, ...$dispatchParam); }; }