https://github.com/dmt-software/http-exception-middleware
psr-15 http exception middleware
https://github.com/dmt-software/http-exception-middleware
Last synced: 3 months ago
JSON representation
psr-15 http exception middleware
- Host: GitHub
- URL: https://github.com/dmt-software/http-exception-middleware
- Owner: dmt-software
- License: mit
- Created: 2022-04-06T09:49:50.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2024-08-30T07:53:06.000Z (over 1 year ago)
- Last Synced: 2025-10-05T01:18:36.480Z (7 months ago)
- Language: PHP
- Size: 17.6 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Http Exception Middleware
PSR-15 middleware to transform http exceptions from _pavelsterba/http-exceptions_ to PSR-7 responses.
## Installation
```bash
composer require dmt-software/http-exception-middleware
```
## Usage
```php
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
```