Skip to content

Laravel middleware to add Accept application/json header to requests

License

Notifications You must be signed in to change notification settings

softonic/laravel-request-accept-json-middleware

Folders and files

NameName
Last commit message
Last commit date

Latest commit

9f9a182 · Jan 16, 2025

History

16 Commits
Jul 26, 2019
Aug 28, 2023
Aug 28, 2023
Aug 29, 2019
Jul 26, 2019
Jul 26, 2019
Nov 2, 2020
Jul 26, 2019
Jul 26, 2019
Nov 2, 2020
Jan 16, 2025
Jan 16, 2025
Jul 26, 2019

Repository files navigation

Laravel request accept json middleware

Latest Version Software License Build Status Coverage Status Quality Score Total Downloads Average time to resolve an issue Percentage of issues still open

This middleware adds the ability to automatically add the Accept application/json header to every request if it was not provided.

Installation

Via composer:

composer require softonic/laravel-request-accept-json-middleware

Documentation

To use the middleware register it in app/Http/Kernel.php

    protected $middleware
        = [
            ...
            RequestAcceptJson::class,
            ...
        ];

From now on the header Accept: application/json will be automatically added to every request.

Testing

softonic/laravel-request-accept-json-middleware has a PHPUnit test suite and a coding style compliance test suite using PHP CS Fixer.

To run the tests, run the following command from the project folder.

$ docker-compose run test

License

The Apache 2.0 license. Please see LICENSE for more information.