This commit is contained in:
as2252258@163.com
2021-09-21 00:43:45 +08:00
parent 4830ada35d
commit 404b367cc2
3 changed files with 15 additions and 2 deletions
+11
View File
@@ -29,6 +29,17 @@ abstract class Handler implements RequestHandlerInterface
protected ?array $middlewares; 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 * @param \Kiri\Proxy\AspectProxy $aspectProxy
*/ */
@@ -3,6 +3,8 @@
namespace Server\Abstracts; 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('<h2>HTTP 404 Not Found</h2><hr><i>Powered by Swoole</i>', $code); parent::__construct('<h2>HTTP 404 Not Found</h2><hr><i>Powered by Swoole</i>', $code);
} }
+1 -1
View File
@@ -81,7 +81,7 @@ class Http extends \Server\Abstracts\Http implements OnClose, OnConnect
{ {
$middlewares = MiddlewareManager::get($handler->callback); $middlewares = MiddlewareManager::get($handler->callback);
$dispatcher = $this->dispatcher->setHandler($handler)->setMiddlewares($middlewares); $dispatcher = new Dispatcher($handler, $middlewares);
return $dispatcher->handle($PsrRequest); return $dispatcher->handle($PsrRequest);
} }