Skip to content

Instantly share code, notes, and snippets.

Avatar
🚀
Working on new projects

RustyNox noxidsoft

🚀
Working on new projects
View GitHub Profile
@meSingh
meSingh / JsonMiddleware.php
Last active Jul 11, 2022
If you are using laravel as api only, you might want to return JSON on every request, even on errors/exceptions. The easiest way to do so is using this middleware globally.
View JsonMiddleware.php
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Http\Request;
class JsonMiddleware
{
public function handle(Request $request, Closure $next)