From dfcf1bf411f4a76be655a400ec33ff8dc13f75b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=B7x?= Date: Thu, 22 Apr 2021 14:43:05 +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/Dispatch/Dispatch.php | 63 -------------------------- HttpServer/Route/Node.php | 7 ++- 2 files changed, 5 insertions(+), 65 deletions(-) delete mode 100644 HttpServer/Route/Dispatch/Dispatch.php diff --git a/HttpServer/Route/Dispatch/Dispatch.php b/HttpServer/Route/Dispatch/Dispatch.php deleted file mode 100644 index 37337e87..00000000 --- a/HttpServer/Route/Dispatch/Dispatch.php +++ /dev/null @@ -1,63 +0,0 @@ -handler = $handler; - if ($handler instanceof Closure) { - $class->bind(); - } - return $class; - } - - - /** - * @return mixed - * 执行函数 - * @throws \Exception - */ - public function dispatch(): mixed - { - $dispatchParam = Context::getContext('dispatch-param'); - if (empty($dispatchParam)) { - $dispatchParam = [\request()]; - } - return \aop($this->handler, $dispatchParam); - } - - - /** - * - */ - protected function bind() - { - $this->handler = Closure::bind($this->handler, new Controller()); - } - -} diff --git a/HttpServer/Route/Node.php b/HttpServer/Route/Node.php index 0d60ef6a..ea56ec33 100644 --- a/HttpServer/Route/Node.php +++ b/HttpServer/Route/Node.php @@ -17,7 +17,6 @@ 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; @@ -127,7 +126,11 @@ class Node extends HttpService public function createDispatch(): Closure { return function () { - return Dispatch::create($this->handler)->dispatch(); + $dispatchParam = Context::getContext('dispatch-param'); + if (empty($dispatchParam)) { + $dispatchParam = [\request()]; + } + return \aop($this->handler, $dispatchParam); }; }