Skip to content

Instantly share code, notes, and snippets.

denniseilander / AsJson.php
Last active Jun 11, 2021
Force http requests and responses as json output. When making requests to an endpoint, there is no need to add the Content-Type and Accept application/json headers anymore.
View AsJson.php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Http\Request;
use Illuminate\Auth\Middleware\Authenticate as Middleware;
class AsJson extends Middleware