laravel-accept-only-json-response maintained by malvik-lab
Laravel accept only Json response
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"
}