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    
Last Updated Ratings Unique User Downloads Download Rankings
2021-02-20 (11 days ago) RSS 2.0 feedNot yet rated by the usersTotal: 26 This week: 2All time: 10,148 This week: 164Up
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
Nominee
Vote
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: 9 packages by
Country: Brazil Brazil
Innovation award
Innovation award
Nominee: 4x

  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:26
This week:2
All time:10,148
This week:164Up

For more information send a message to info at phpclasses dot org.