From f647b5bd39c47785c43089c320ed48bbba942d3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=B7x?= Date: Tue, 20 Apr 2021 13:48:33 +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 | 3 +++ HttpServer/Route/Reduce.php | 25 ++++++++++++++++++------- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/HttpServer/Route/Node.php b/HttpServer/Route/Node.php index 7491fcdc..0ee00bcf 100644 --- a/HttpServer/Route/Node.php +++ b/HttpServer/Route/Node.php @@ -532,6 +532,9 @@ class Node extends HttpService if ($this->handler instanceof Closure) { return call_user_func($this->handler, ...$dispatchParams); } + + var_dump($dispatchParams); + $validator = $this->getValidator(); if (!($validator instanceof Validator)) { return call_user_func($this->callback, ...$dispatchParams); diff --git a/HttpServer/Route/Reduce.php b/HttpServer/Route/Reduce.php index b8b81452..dfe94bee 100644 --- a/HttpServer/Route/Reduce.php +++ b/HttpServer/Route/Reduce.php @@ -52,13 +52,24 @@ class Reduce private static function core(): Closure { return function ($stack, $pipe) { - return function ($passable) use ($stack, $pipe) { - if ($pipe instanceof Middleware) { - return $pipe->onHandler($passable, $stack); - } else { - return call_user_func($pipe, $passable, $stack); - } - }; + return static::passable($stack, $pipe); + }; + } + + + /** + * @param $stack + * @param $pipe + * @return Closure + */ + public static function passable($stack, $pipe): Closure + { + return function ($passable) use ($stack, $pipe) { + if (!($pipe instanceof Middleware)) { + return call_user_func($pipe, $passable, $stack); + } else { + return $pipe->onHandler($passable, $stack); + } }; }