From b467e048622c49987c89939abbc14975eddd50dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=B7x?= Date: Thu, 15 Oct 2020 11:59:42 +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 5519ddfa..464e1787 100644 --- a/HttpServer/Route/Node.php +++ b/HttpServer/Route/Node.php @@ -390,19 +390,20 @@ class Node extends Application /** - * @param string $class + * @param string|\Closure $class * @throws Exception */ - public function addMiddleware(string $class) + public function addMiddleware($class) { + if (!is_callable($class, true)) { + return; + } if (is_string($class)) { $class = Snowflake::createObject($class); if (!($class instanceof \HttpServer\IInterface\Middleware)) { return; } $class = [$class, 'handler']; - } else if (!is_callable($class, true)) { - return; } $this->middleware[] = $class; $this->restructure();