From b059bb2d1a6ca090202f8569d00d6cd770a657c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=B7x?= Date: Sat, 18 Sep 2021 11:23:10 +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 --- http-handler/Abstracts/Handler.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/http-handler/Abstracts/Handler.php b/http-handler/Abstracts/Handler.php index 6d4c2b00..3b93895a 100644 --- a/http-handler/Abstracts/Handler.php +++ b/http-handler/Abstracts/Handler.php @@ -56,14 +56,14 @@ abstract class Handler implements RequestHandlerInterface protected function dispatcher(): mixed { if ($this->handler->callback instanceof \Closure) { - return call_user_func($this->handler->callback, ...$this->handler->params); + $response = call_user_func($this->handler->callback, ...$this->handler->params); + } else { + [$controller, $action] = $this->handler->callback; + $controller = Kiri::getDi()->get($controller); + + $response = call_user_func([$controller, $action], ...$this->handler->params); } - [$controller, $action] = $this->handler->callback; - - $controller = Kiri::getDi()->get($controller); - - $response = call_user_func([$controller, $action], ...$this->handler->params); if (!($response instanceof ResponseInterface)) { $response = $this->transferToResponse($response); }