Skip to content
This repository has been archived by the owner on Jul 6, 2024. It is now read-only.

Latest commit

 

History

History
33 lines (25 loc) · 755 Bytes

ApiExceptionMiddleware.md

File metadata and controls

33 lines (25 loc) · 755 Bytes

ApiExceptionMiddleware

<?php

use Chubbyphp\ApiHttp\Manager\ResponseManagerInterface;
use Chubbyphp\ApiHttp\Middleware\ApiExceptionMiddleware;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Server\RequestHandlerInterface;
use Psr\Log\LoggerInterface;

/** @var ServerRequestInterface $request */
$request = ...;

/** @var RequestHandlerInterface $handler */
$handler = ...;

/** @var ResponseManagerInterface $responseManager */
$responseManager = ...;

/** @var LoggerInterface $logger */
$logger = ...;

$middleware = new ApiExceptionMiddleware(
    $responseManager,
    true,
    $logger
);

/** @var ResponseInterface $response */
$response = $middleware->process($request, $handler);