1 | <?php |
||
22 | |||
23 | class QueueRunner implements RequestHandlerInterface{ |
||
24 | |||
25 | /** |
||
26 | * @var \Psr\Http\Server\MiddlewareInterface[] |
||
27 | */ |
||
28 | private array $middlewareStack; |
||
|
|||
29 | |||
30 | /** |
||
31 | * @var \Psr\Http\Server\RequestHandlerInterface |
||
32 | */ |
||
33 | private RequestHandlerInterface $fallbackHandler; |
||
34 | |||
35 | /** |
||
36 | * constructor. |
||
37 | * |
||
38 | * @param array $middlewareStack |
||
39 | * @param \Psr\Http\Server\RequestHandlerInterface $fallbackHandler |
||
40 | */ |
||
41 | public function __construct(array $middlewareStack, RequestHandlerInterface $fallbackHandler){ |
||
42 | $this->middlewareStack = $middlewareStack; |
||
43 | $this->fallbackHandler = $fallbackHandler; |
||
44 | } |
||
45 | |||
46 | /** |
||
47 | * @inheritDoc |
||
48 | */ |
||
49 | public function handle(ServerRequestInterface $request):ResponseInterface{ |
||
50 | |||
51 | if(empty($this->middlewareStack)){ |
||
52 | return $this->fallbackHandler->handle($request); |
||
53 | } |
||
54 | |||
55 | return $this->getMiddleware()->process($request, $this); |
||
56 | } |
||
57 | |||
58 | /** |
||
59 | * @return \Psr\Http\Server\MiddlewareInterface |
||
60 | */ |
||
66 |