2017-12-29 12:50:07 +08:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Set the content type in the API layer
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace App\Http\Middleware;
|
|
|
|
|
2019-11-27 22:19:20 +08:00
|
|
|
use App\Contracts\Middleware;
|
2017-12-29 12:50:07 +08:00
|
|
|
use Closure;
|
2019-11-27 22:19:20 +08:00
|
|
|
use Illuminate\Http\Request;
|
2017-12-29 12:50:07 +08:00
|
|
|
|
2019-11-27 22:19:20 +08:00
|
|
|
class JsonResponse implements Middleware
|
2017-12-29 12:50:07 +08:00
|
|
|
{
|
2019-11-27 22:19:20 +08:00
|
|
|
public function handle(Request $request, Closure $next)
|
2017-12-29 12:50:07 +08:00
|
|
|
{
|
|
|
|
$response = $next($request);
|
|
|
|
$response->headers->set('Content-Type', 'application/json');
|
2018-03-20 09:50:40 +08:00
|
|
|
|
2017-12-29 12:50:07 +08:00
|
|
|
return $response;
|
|
|
|
}
|
|
|
|
}
|