-
Notifications
You must be signed in to change notification settings - Fork 11.1k
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
[6.0] Moved Response code from the Pipeline to the Routing Pipeline #29273
Conversation
Responsable check is now done on the Route Pipeline. This cleans the Base Pipeline class, avoiding unwanted behaviour when using it with Responsable objects. Also added a test to check if a Middleware that returns a Responsable (instead of keep going with the pipeline) transforms it to a Response.
Fuck yeah all green. Hitting the bed til tomorrow. |
This reverts commit 0a7f73f
Please describe any breaking changes users would need to account for. |
For developers using the Pipeline class, if a pipe returns a value it will be returned next as-is. The Pipeline won't check if the value returned by a pipe is a Responsable instance and transform it to a Response instance. The Pipeline is used on the Middleware processing, which will keep that behaviour. That means, if one the middlewares returns a Responsable class, it will be automatically transformed to a Response. |
Hey Note that this would negate the effect of #29251. But if the Laravel team is OK to move this special handling of Responsable objects exclusively for the middleware and in the Routing Pipeline, could we consider adding a hook method instead of overriding the whole The end of the try block in the carry method would then be: $response = method_exists($pipe, $this->method)
? $pipe->{$this->method}(...$parameters)
: $pipe(...$parameters);
return $this->handleResponse($response); In the base class the method would just return the response, but in the Routing Pipeline it would be: protected function handleResponse($response)
{
return $response instanceof Responsable
? $response->toResponse($this->getContainer()->make(Request::class))
: $response;
} |
… overridden by the Routing Pipeline to check for a Responsable instance.
Welp, that seems better. Does the code looks more understandable now? |
I think this should be more important now that the Pipeline class is being used for Job Middlewares |
Responsable check is now done on the Route Pipeline. This cleans the Base Pipeline class, avoiding unwanted behaviour when using it with Responsable objects in other parts of the developer application.
Also added a test to check if a Middleware that returns a Responsable (instead of keep going with the pipeline) transforms it to a Response.