From 9718649ddd6ea9c226b8819fb35e33b0cb130258 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=B7x?= Date: Fri, 5 Mar 2021 18:05:45 +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 | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/HttpServer/Route/Node.php b/HttpServer/Route/Node.php index cbe5e489..fd110854 100644 --- a/HttpServer/Route/Node.php +++ b/HttpServer/Route/Node.php @@ -69,9 +69,7 @@ class Node extends HttpService */ public function bindHandler($handler): static { - if ($handler instanceof Closure) { - $this->handler = $handler; - } else if (is_string($handler) && str_contains($handler, '@')) { + if (is_string($handler) && str_contains($handler, '@')) { list($controller, $action) = explode('@', $handler); if (!empty($this->namespace)) { $controller = implode('\\', $this->namespace) . '\\' . $controller; @@ -79,13 +77,15 @@ class Node extends HttpService $this->handler = $this->getReflect($controller, $action); } else if ($handler != null && !is_callable($handler, true)) { $this->_error = 'Controller is con\'t exec.'; + } else if ($handler instanceof Closure) { + $this->handler = $handler; } else { [$controller, $action] = $this->handler = $handler; - if ($controller instanceof Controller) { - $this->annotationInject(get_class($controller), $action); - - $this->callback = Reduce::reduce($this->createDispatch(), $this->annotation()); + if (!($controller instanceof Controller)) { + return $this; } + $this->annotationInject(get_class($controller), $action); + $this->callback = Reduce::reduce($this->createDispatch(), $this->annotation()); } return $this; }