-
Notifications
You must be signed in to change notification settings - Fork 11.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[5.5] Ensure Router returns a JsonResponse for Arrayable, Jsonable (...) #17875
[5.5] Ensure Router returns a JsonResponse for Arrayable, Jsonable (...) #17875
Conversation
What is the actual benefit of this? |
They are many @taylorotwell , in a normal Response, you cannot get and set the encoding option, you cannot set the callback either. This PR solves that. |
I really feel like instead of all this header business you should just check for Arrayable or Jsonable in the |
@taylorotwell , the check is now done in the Router; see a7edae8. |
👎 This forces people to use json at the router level. |
What if they wanted a streamed json resource too? |
@GrahamCampbell I don't follow. We were returning |
src/Illuminate/Routing/Router.php
Outdated
*/ | ||
public function prepareResponse($request, $response) | ||
{ | ||
if ($response instanceof PsrResponseInterface) { | ||
$response = (new HttpFoundationFactory)->createResponse($response); | ||
} elseif (! $response instanceof SymfonyResponse) { | ||
$response = new Response($response); | ||
if ($response instanceof Arrayable || |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
too many spaces
Ah, right, probably fine then. |
For now only a normal
Response
, mimicing aJsonResponse
is returned; this enforces aJsonResponse
to be returned.A much more performant way to achieve #17869 /cc @taylorotwell