Better json response using laravel’s helper

This commit is contained in:
Jonny Barnes 2016-10-03 16:26:58 +01:00
parent 46f1bfd99f
commit 46ed129904

View file

@ -115,16 +115,11 @@ class MicropubController extends Controller
$valid = $this->tokenService->validateToken($token);
if ($valid === null) {
$content = <<<'EOD'
{
"respose": "error",
"error": "invalid_token",
"error_description": "The provided token did not pass validation"
}
EOD;
return (new Response($content, 400))
->header('Content-Type', 'application/json');
return response()->json([
'response' => 'error',
'error' => 'invalid_token',
'error_description' => 'The provided token did not pass validation'
], 400);
}
//we have a valid token, is `syndicate-to` set?
if ($request->input('q') === 'syndicate-to') {