Last active
March 4, 2020 08:43
-
-
Save fagci/f4df62f39b912f819a0e7205541f551e to your computer and use it in GitHub Desktop.
Laravel / Lumen json options for response using middleware. Used for returning unescaped utf-8 unicode response.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Http\Middleware; | |
use Closure; | |
class UnescapedJsonMiddleware | |
{ | |
public function handle($request, Closure $next) | |
{ | |
$data = $next($request); | |
$data->setEncodingOptions(JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES); | |
return $data; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment