Skip to content

Commit

Permalink
comments
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshuaEstes committed Dec 6, 2023
1 parent ba08051 commit 0119a8f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/SonsOfPHP/Component/HttpHandler/HttpHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {}
Expand Down
6 changes: 6 additions & 0 deletions src/SonsOfPHP/Component/HttpHandler/MiddlewareStack.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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));
Expand Down

0 comments on commit 0119a8f

Please sign in to comment.