RequestHandlerRunner
in package
implements
RequestHandlerRunnerInterface
"Run" a request handler.
The RequestHandlerRunner will marshal a request using the composed factory, and then pass the request to the composed handler. Finally, it emits the response returned by the handler using the composed emitter.
If the factory for generating the request raises an exception or throwable, then the runner will use the composed error response generator to generate a response, based on the exception or throwable raised.
Table of Contents
Interfaces
- RequestHandlerRunnerInterface
- "Run" a request handler.
Properties
- $emitter : EmitterInterface
- $handler : RequestHandlerInterface
- A request handler to run as the application.
- $serverRequestErrorResponseGenerator : callable(Throwable): ResponseInterface
- A factory capable of generating an error response in the scenario that the $serverRequestFactory raises an exception during generation of the request instance.
- $serverRequestFactory : callable(): ServerRequestInterface
- A factory capable of generating a Psr\Http\Message\ServerRequestInterface instance.
Methods
- __construct() : mixed
- run() : void
- Run the application
- emitMarshalServerRequestException() : void
Properties
$emitter
private
EmitterInterface
$emitter
$handler
A request handler to run as the application.
private
RequestHandlerInterface
$handler
$serverRequestErrorResponseGenerator
A factory capable of generating an error response in the scenario that the $serverRequestFactory raises an exception during generation of the request instance.
private
callable(Throwable): ResponseInterface
$serverRequestErrorResponseGenerator
The factory will receive the Throwable or Exception that caused the error, and must return a Psr\Http\Message\ResponseInterface instance.
$serverRequestFactory
A factory capable of generating a Psr\Http\Message\ServerRequestInterface instance.
private
callable(): ServerRequestInterface
$serverRequestFactory
The factory will not receive any arguments.
Methods
__construct()
public
__construct(RequestHandlerInterface $handler, EmitterInterface $emitter, callable(): ServerRequestInterface $serverRequestFactory, callable(Throwable): ResponseInterface $serverRequestErrorResponseGenerator) : mixed
Parameters
- $handler : RequestHandlerInterface
- $emitter : EmitterInterface
- $serverRequestFactory : callable(): ServerRequestInterface
- $serverRequestErrorResponseGenerator : callable(Throwable): ResponseInterface
run()
Run the application
public
run() : void
emitMarshalServerRequestException()
private
emitMarshalServerRequestException(Throwable $exception) : void
Parameters
- $exception : Throwable