Skip to content

Commit aea5fc8

Browse files
resolve di from dispatch method
1 parent 6065f55 commit aea5fc8

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/Dispatcher.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ trait Dispatcher
3131
* @var mixed The value for the not found route.
3232
*/
3333
protected $notFound;
34-
34+
3535

3636
/**
3737
* Dispatcher constructor.
@@ -68,8 +68,7 @@ public function dispatch(ServerRequestInterface $request): ResponseInterface
6868

6969
if (!$this->notFound) {
7070

71-
return $this->notFoundResponse();
72-
71+
return $this->notFoundResponse();
7372
}
7473

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

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

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

0 commit comments

Comments
 (0)