This repository has been archived by the owner on Jan 6, 2023. It is now read-only.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds a new action called
response
. It will fire whenever the API is responding to the client.Why
The existing
filters
hookresponse
allows you to change the JSON output for successful response, however, it doesn't give you any information on the request/response and it doesn't fire on unsuccessful requests, like 405s or 400s. Also,filters
are meant to be used to modify the JSON output, while actions are meant to be used for other purposes. This action can be used to integrate some sort of logging service via web hooks into the API.Usage
Notes
For some reason,
$this->emitter
isnull
for theMethodNotAllowedHandler
. I wasn't able to figure out whyNotFoundHandler
has aemitter
, butMethodNotAllowedHandler
doesn't. Maybe you can shed some light on that @wellingguzman?I'm not too happy about the fact that the
triggerResponseAction
is duplicated in 2 files. I wasn't sure if you like it to be a separate file or not @wellingguzman.