Laravel JSON Request Validation: Disallow HTTP requests that do not accept JSON

Recommend this page to a friend!
  Info   View files View files (4)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog (1)    
Last Updated Ratings Unique User Downloads Download Rankings
2021-02-20 (8 months ago) RSS 2.0 feedNot yet rated by the usersTotal: 32 All time: 10,296 This week: 228Up
Version License PHP version Categories
laravel-enforce-json 0.0.1MIT/X Consortium ...7.2HTTP, PHP 5, Validation
Description Author

This class is a middleware that can disallow HTTP requests that do not accept JSON.

It checks the current HTTP request to check the values for the Accept header.

The class will return HTTP status 400 if the application/json MIME type is not in the headers that the client accepts.

Innovation Award
PHP Programming Innovation award nominee
February 2021
Number 5
There are certain types of applications, like for instance APIs, that only serve data values as responses.

JSON is nowadays a common format to serve HTTP responses with data values represented as text.

When an API application is only meant to serve JSON based responses, it is useful to refuse serving requests from clients that are not ready to take JSON based responses, like for instance requests from regular browsers that expect HTML pages.

This package provides a solution that can be used in Laravel based applications to refuse serving HTTP requests from clients that are not ready to handle JSON based responses.

Manuel Lemos
Picture of Thiago Przyczynski
  Performance   Level  
Name: Thiago Przyczynski <contact>
Classes: 13 packages by
Country: Brazil Brazil
Age: 32
All time rank: 3353257 in Brazil Brazil
Week rank: 150 Up4 in Brazil Brazil Up
Innovation award
Innovation award
Nominee: 6x

  Files folder image Files  
File Role Description
Files folder imagesrc (1 file)
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file License.txt Doc. Documentation
Plain text file README.md Class Class source

  Files folder image Files  /  src  
File Role Description
  Plain text file EnforceJson.php Class Class source

 Version Control Unique User Downloads Download Rankings  
 100%
Total:32
This week:0
All time:10,296
This week:228Up
For more information send a message to info at phpclasses dot org.