Skip to content

Instantly share code, notes, and snippets.

@denniseilander
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
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Http\Request;
use Illuminate\Auth\Middleware\Authenticate as Middleware;
class AsJson extends Middleware
{