From 0119a8f7ff3aee3e8487e7dcd5f523a836a65677 Mon Sep 17 00:00:00 2001 From: Joshua Estes Date: Wed, 6 Dec 2023 18:09:11 -0500 Subject: [PATCH] comments --- src/SonsOfPHP/Component/HttpHandler/HttpHandler.php | 2 +- src/SonsOfPHP/Component/HttpHandler/MiddlewareStack.php | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/SonsOfPHP/Component/HttpHandler/HttpHandler.php b/src/SonsOfPHP/Component/HttpHandler/HttpHandler.php index 19895843..d68de19c 100644 --- a/src/SonsOfPHP/Component/HttpHandler/HttpHandler.php +++ b/src/SonsOfPHP/Component/HttpHandler/HttpHandler.php @@ -8,7 +8,7 @@ use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; -// RequestHandler? +// ServerRequestHandler? RequestHandler? class HttpHandler implements RequestHandlerInterface { public function __construct(private MiddlewareStack $stack) {} diff --git a/src/SonsOfPHP/Component/HttpHandler/MiddlewareStack.php b/src/SonsOfPHP/Component/HttpHandler/MiddlewareStack.php index 95e2d08e..eaa707b1 100644 --- a/src/SonsOfPHP/Component/HttpHandler/MiddlewareStack.php +++ b/src/SonsOfPHP/Component/HttpHandler/MiddlewareStack.php @@ -6,17 +6,22 @@ use Psr\Http\Server\MiddlewareInterface; +// @todo implement interface (make contract) class MiddlewareStack { private array $middlewares = []; + private $resolver; public function __construct($resolver) { $this->resolver = $resolver; } + // @todo Set Priorities public function add($middleware): self { + // $this->middlewares[$priority][] = $middleware; + // ksort($this->middlewares); $this->middlewares[] = $middleware; return $this; @@ -43,6 +48,7 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface if (is_string($middleware)) { // use the resolver to figure out wtf this is + return $this->resolver($middleware); } throw new \Exception('Unknown Middleware Type: ' . gettype($middleware));