From ac275ed032bc7884e968ebd2a09407e4db71de9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=B7x?= Date: Mon, 8 Mar 2021 17:23:16 +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/Router.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/HttpServer/Route/Router.php b/HttpServer/Route/Router.php index 339ed0cb..e85813d9 100644 --- a/HttpServer/Route/Router.php +++ b/HttpServer/Route/Router.php @@ -79,7 +79,9 @@ class Router extends HttpService implements RouterInterface */ public function addPortListen($port, Closure|array|string $closure, $method = null) { - if (is_string($closure)) { + if (!is_string($closure)) { + $this->addRoute('add-port-listen/port_' . $port, $closure, 'listen'); + } else { if (empty($method)) { throw new NotFindClassException($closure . '::' . $method); } @@ -87,10 +89,8 @@ class Router extends HttpService implements RouterInterface if (!method_exists($_closure, $method)) { throw new NotFindClassException($closure . '::' . $method); } - - $closure = [$closure, $method]; + $this->addRoute('add-port-listen/port_' . $port, [$_closure, $method], 'listen'); } - $this->addRoute('add-port-listen/port_' . $port, $closure, 'listen'); }