dmt-software / http-exception-middleware
psr-15 http exception middleware
Installs: 8 868
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 3
Forks: 0
Open Issues: 0
Requires
- pavelsterba/http-exceptions: ^1.1
- psr/http-factory: ^1.0
- psr/http-message: ^1.0 | ^2.0
- psr/http-server-middleware: ^1.0
Requires (Dev)
- guzzlehttp/psr7: ^2.2
- phpunit/phpunit: ^9.5
README
PSR-15 middleware to transform http exceptions from pavelsterba/http-exceptions to PSR-7 responses.
Installation
composer require dmt-software/http-exception-middleware
Usage
use DMT\Http\Exception\Middleware\HttpExceptionMiddleware; use Psr\Http\Message\ResponseFactoryInterface; use Psr\Http\Message\ServerRequestInterface; use Psr\Http\Server\RequestHandlerInterface; /** @var ResponseFactoryInterface $httpExceptionMiddleware */ $httpExceptionMiddleware = new HttpExceptionMiddleware($responseFactory); /** @var ServerRequestInterface $request */ /** @var RequestHandlerInterface $handler */ $httpExceptionMiddleware->process($request, $handler); // if handler throws a HttpException/Exception it will be turned into a psr-7 response