From 723832722a665a153b3506667ff537a88817c5a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=B7x?= Date: Tue, 20 Apr 2021 11:45:39 +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 | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/HttpServer/Route/Node.php b/HttpServer/Route/Node.php index f50902a8..cb76c185 100644 --- a/HttpServer/Route/Node.php +++ b/HttpServer/Route/Node.php @@ -115,7 +115,9 @@ class Node extends HttpService $this->annotationInject(get_class($controller), $action); } if (!empty($this->handler)) { - $this->callback = Reduce::reduce($this->createDispatch(), $this->annotation()); + $this->callback = Reduce::reduce(function () { + return call_user_func($this->handler, ...func_get_args()); + }, $this->annotation()); } return $this; } @@ -199,6 +201,7 @@ class Node extends HttpService /** * @param null $response * @return mixed + * @throws Exception */ public function afterDispatch($response = null): mixed { @@ -483,11 +486,8 @@ class Node extends HttpService /** - * @param array|Closure|string $class - * @return Node - * @throws ReflectionException - * @throws NotFindClassException - * @throws Exception + * @param Closure|array $class + * @return $this */ public function addMiddleware(Closure|array $class): static { @@ -534,6 +534,8 @@ class Node extends HttpService if ($this->handler instanceof Closure) { return call_user_func($this->handler, ...func_get_args()); } + return $this->runWith($this->callback, ...func_get_args()); + return $this->runFilter(...func_get_args()); } catch (Throwable $throwable) { $this->addError($throwable, 'throwable');