Introduce new middlewares to enforce JSON acceptance and manage ETag headers for API responses.
27 lines
688 B
PHP
27 lines
688 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
use Illuminate\Foundation\Configuration\Middleware;
|
|
use Presentation\Api\V1\Http\Middlewares\EnsureApiV1AcceptsJson;
|
|
use Presentation\Api\V1\Http\Middlewares\SetApiV1Etag;
|
|
use Presentation\Api\V1\Http\Middlewares\TransformApiV1Response;
|
|
|
|
return function (Middleware $middleware): void {
|
|
$middleware->web(append: [
|
|
'throttle:web',
|
|
]);
|
|
|
|
$middleware->api(append: []);
|
|
|
|
$middleware->group('api.v1', [
|
|
EnsureApiV1AcceptsJson::class,
|
|
'throttle:api.v1',
|
|
SetApiV1Etag::class,
|
|
TransformApiV1Response::class,
|
|
]);
|
|
|
|
$middleware->preventRequestsDuringMaintenance(except: [
|
|
'errors/*',
|
|
]);
|
|
};
|