From 6560ea493082d40dd905af0b2bd7f2e14b735edb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=B7x?= Date: Thu, 20 May 2021 15:02:46 +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 | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/HttpServer/Route/Node.php b/HttpServer/Route/Node.php index 13e1d605..538b98b3 100644 --- a/HttpServer/Route/Node.php +++ b/HttpServer/Route/Node.php @@ -121,15 +121,16 @@ class Node extends HttpService */ public function createDispatch(): Closure { - return static function () { + $handler = $this->handler; + return static function () use ($handler) { $dispatchParam = Context::getContext('dispatch-param'); if (empty($dispatchParam)) { $dispatchParam = [\request()]; } - if ($this->handler instanceof Closure) { - return call_user_func($this->handler, ...$dispatchParam); + if ($handler instanceof Closure) { + return call_user_func($handler, ...$dispatchParam); } - return \aop($this->handler, $dispatchParam); + return \aop($handler, $dispatchParam); }; }