softonic / laravel-request-accept-json-middleware
Laravel middleware to add Accept application/json header to requests
Installs: 38 030
Dependents: 0
Suggesters: 0
Security: 0
Stars: 4
Watchers: 2
Forks: 0
Open Issues: 0
Requires
- php: >=7.2
- illuminate/contracts: ^8.0 || ^9.0 || ^10.0
- illuminate/http: ^8.0 || ^9.0 || ^10.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^2.16
- mockery/mockery: ^1.2
- phpunit/phpunit: ^9.0
This package is auto-updated.
Last update: 2024-10-28 11:43:46 UTC
README
This middleware adds the ability to automatically add the Accept application/json header to every request if it was not provided.
Installation
Via composer:
composer require softonic/laravel-request-accept-json-middleware
Documentation
To use the middleware register it in app/Http/Kernel.php
protected $middleware
= [
...
RequestAcceptJson::class,
...
];
From now on the header Accept: application/json
will be automatically added to every request.
Testing
softonic/laravel-request-accept-json-middleware
has a PHPUnit test suite and a coding style compliance test suite using PHP CS Fixer.
To run the tests, run the following command from the project folder.
$ docker-compose run test
License
The Apache 2.0 license. Please see LICENSE for more information.