Skip to content

Commit

Permalink
resolve di from dispatch method
Browse files Browse the repository at this point in the history
  • Loading branch information
BMTmohammedtaha committed Dec 12, 2023
1 parent 6065f55 commit aea5fc8
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/Dispatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ trait Dispatcher
* @var mixed The value for the not found route.
*/
protected $notFound;


/**
* Dispatcher constructor.
Expand Down Expand Up @@ -68,8 +68,7 @@ public function dispatch(ServerRequestInterface $request): ResponseInterface

if (!$this->notFound) {

return $this->notFoundResponse();

return $this->notFoundResponse();
}

$controller->setCallback($this->notFound);
Expand All @@ -78,7 +77,9 @@ public function dispatch(ServerRequestInterface $request): ResponseInterface
// handle router middlewares
if (!empty($action['middleware'])) {

$handler = new RequestHandler($this->response, $action['middleware']);
$middlewares = array_map(fn ($m) => Resolver::resolveClass($m), $action['middleware']);

$handler = new RequestHandler($this->response, $middlewares);

$responseMiddleware = $this->runMiddleware($this->request, $handler);

Expand Down

0 comments on commit aea5fc8

Please sign in to comment.