From d0750a95a75c2569460d5f870aacbcdaefb7b7d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=B7x?= Date: Tue, 15 Dec 2020 18:56:23 +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 | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/HttpServer/Route/Node.php b/HttpServer/Route/Node.php index f4318438..fa04f040 100644 --- a/HttpServer/Route/Node.php +++ b/HttpServer/Route/Node.php @@ -395,9 +395,6 @@ class Node extends Application */ public function addMiddleware(Closure|string|array $class) { - if (!is_callable($class, true)) { - return; - } if (is_string($class)) { $class = Snowflake::createObject($class); if (!($class instanceof \HttpServer\IInterface\Middleware)) { @@ -405,7 +402,12 @@ class Node extends Application } $class = [$class, 'onHandler']; } - $this->middleware[] = $class; + if (!is_array($class) || is_object($class[0])) { + $class = [$class]; + } + foreach ($class as $closure) { + $this->middleware[] = $closure; + } $this->restructure(); }