Make initial server request available to middlewares
This commit is contained in:
parent
5c83208450
commit
11e9d4e827
|
@ -35,6 +35,11 @@ use Psr\Http\Server\RequestHandlerInterface;
|
||||||
*/
|
*/
|
||||||
abstract class AbstractMiddleware implements MiddlewareInterface
|
abstract class AbstractMiddleware implements MiddlewareInterface
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* The PSR-15 Server Request Handler.
|
||||||
|
*/
|
||||||
|
protected RequestHandlerInterface $handler;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The PSR-7 HTTP Server Request after processing.
|
* The PSR-7 HTTP Server Request after processing.
|
||||||
*/
|
*/
|
||||||
|
@ -56,6 +61,7 @@ abstract class AbstractMiddleware implements MiddlewareInterface
|
||||||
*/
|
*/
|
||||||
final public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
|
final public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
|
||||||
{
|
{
|
||||||
|
$this->handler = $handler;
|
||||||
// Manipulate request if necessary.
|
// Manipulate request if necessary.
|
||||||
$this->request = $this->processRequest($request);
|
$this->request = $this->processRequest($request);
|
||||||
// Delegate request to next middleware and get response.
|
// Delegate request to next middleware and get response.
|
||||||
|
|
|
@ -152,6 +152,17 @@ class QueueRequestHandler implements RequestHandlerInterface
|
||||||
return $this->queue;
|
return $this->queue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Magic getter method for $this->request.
|
||||||
|
* @see Getter
|
||||||
|
*
|
||||||
|
* @return ServerRequestInterface The PSR-7 server request
|
||||||
|
*/
|
||||||
|
protected function magicGetRequest(): ServerRequestInterface
|
||||||
|
{
|
||||||
|
return $this->request;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a queue-based PSR-15 HTTP Server Request Handler.
|
* Create a queue-based PSR-15 HTTP Server Request Handler.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue