Looking to hire Laravel developers? Try LaraJobs

laravel-accept-only-json-response maintained by malvik-lab

Description
Block requests that don't accept json in response.
Last update
2021/09/14 15:28 (dev-main)
License
Links
Downloads
50
Tags

Comments
comments powered by Disqus

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"
}