PHP Classes

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

Recommend this page to a friend!
     
  Info   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 40 All time: 10,888 This week: 71Up
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: 35
All time rank: 3194238 in Brazil Brazil
Week rank: 180 Up12 in Brazil Brazil Up
Innovation award
Innovation award
Nominee: 8x

  Files folder image Files (4)  
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 (4)  /  src  
File Role Description
  Plain text file EnforceJson.php Class Class source

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 100%
Total:40
This week:0
All time:10,888
This week:71Up