Add middleware to set Content-type to application/json on all API requests

This commit is contained in:
Nabeel Shahzad
2017-12-28 22:50:07 -06:00
parent d04c11f660
commit a5c5518a12
2 changed files with 20 additions and 0 deletions

View File

@@ -0,0 +1,18 @@
<?php
/**
* Set the content type in the API layer
*/
namespace App\Http\Middleware;
use Closure;
class JsonResponse
{
public function handle($request, Closure $next)
{
$response = $next($request);
$response->headers->set('Content-Type', 'application/json');
return $response;
}
}