PHP Classes

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)    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 38 All time: 10,852 This week: 131Up
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: 16 packages by
Country: Brazil Brazil
Age: 34
All time rank: 3206238 in Brazil Brazil
Week rank: 312 Up26 in Brazil Brazil Up
Innovation award
Innovation award
Nominee: 8x

  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:38
This week:0
All time:10,852
This week:131Up