Skip to content

Instantly share code, notes, and snippets.

@fagci
Last active March 4, 2020 08:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fagci/f4df62f39b912f819a0e7205541f551e to your computer and use it in GitHub Desktop.
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.
<?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