From 404b367cc26f3635206f6f410137d26475d6accd Mon Sep 17 00:00:00 2001 From: "as2252258@163.com" Date: Tue, 21 Sep 2021 00:43:45 +0800 Subject: [PATCH] 111 --- http-handler/Abstracts/Handler.php | 11 +++++++++++ http-server/Abstracts/PageNotFoundException.php | 4 +++- http-server/Service/Http.php | 2 +- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/http-handler/Abstracts/Handler.php b/http-handler/Abstracts/Handler.php index e076add9..2f0da962 100644 --- a/http-handler/Abstracts/Handler.php +++ b/http-handler/Abstracts/Handler.php @@ -29,6 +29,17 @@ abstract class Handler implements RequestHandlerInterface protected ?array $middlewares; + /** + * @param \Http\Handler\Handler $handler + * @param array|null $middlewares + */ + public function __construct(CHl $handler, ?array $middlewares) + { + $this->handler = $handler; + $this->middlewares = $middlewares; + } + + /** * @param \Kiri\Proxy\AspectProxy $aspectProxy */ diff --git a/http-server/Abstracts/PageNotFoundException.php b/http-server/Abstracts/PageNotFoundException.php index 3e829973..09b99498 100644 --- a/http-server/Abstracts/PageNotFoundException.php +++ b/http-server/Abstracts/PageNotFoundException.php @@ -3,6 +3,8 @@ namespace Server\Abstracts; +use JetBrains\PhpStorm\Pure; + /** * */ @@ -13,7 +15,7 @@ class PageNotFoundException extends \Exception /** * */ - public function __construct(int $code) + #[Pure] public function __construct(int $code) { parent::__construct('

HTTP 404 Not Found


Powered by Swoole', $code); } diff --git a/http-server/Service/Http.php b/http-server/Service/Http.php index 3b4bffab..b1832e77 100644 --- a/http-server/Service/Http.php +++ b/http-server/Service/Http.php @@ -81,7 +81,7 @@ class Http extends \Server\Abstracts\Http implements OnClose, OnConnect { $middlewares = MiddlewareManager::get($handler->callback); - $dispatcher = $this->dispatcher->setHandler($handler)->setMiddlewares($middlewares); + $dispatcher = new Dispatcher($handler, $middlewares); return $dispatcher->handle($PsrRequest); }