-
Notifications
You must be signed in to change notification settings - Fork 11.7k
[12.x] Add ability to run callbacks after building an Http response #58088
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
Conversation
3875870 to
9af6bd7
Compare
| $this->dispatchResponseReceivedEvent($response); | ||
| $response = $this->runAfterResponseCallbacks($response); |
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.
I'm not positive which of these should run first, to be honest.
|
@cosmastech could this method just be named |
I think I don't think it creates a code conflict with promises, though it may be confusing. One instance of You're the guy with the good names, so I'll leave it up to you 😆 |
While we can add middleware to the Guzzle stack, it doesn't actually build the Response object, which I would like to inspect and mutate.
An Example
While obviously all of this can be done currently, it requires every developer to remember to run that pipeline on their response. We could make a macro that actually posts the response and maps it, however, that doesn't allow for mutating on a per request basis before sending (such as adding an additional header or setting throws() or a timeout).