malvik-lab / laravel-accept-only-json-response
Block requests that don't accept json in response.
1.0.1
2021-09-14 13:28 UTC
README
If you need in Laravel PHP Framework to serve only Json requests, this package is the solution.
Installation
$ composer require malvik-lab/laravel-accept-only-json-response
Use on your routes
Route::middleware(['malviklab-laravel-accept-only-json-response'])->group(function () { // your routes here });
Output (if the request is incorrect)
Http status code: 400 Bad Request
{ "error": "Use the \"Accept: application/json\" HTTP Header" }