-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
how to implement a "after-route" policy #2387
Comments
That's currently not possible. You can, however, use responses for this. Simply create a new response in |
The recommended practice at this point is to use |
@tjwebb Correct. That's what I'm saying. All controller.actions, by default, use res.ok() for successful responses and res.negotiate() for errors. res.negotiate() figures out if it should call badRequest(), serverError(). There's also a notFound() response. The convention is to use one of these for your response (in favour of res.send() or res.json()). |
I'm currently using an additional config file for api format, using a service to do the formatting, and overwriting the blueprints to call the service |
Can anyone update this with an answer to @leejt489 ? |
From my understanding, |
I like how policies separate my controller logic from guard logic. But I need a policy to run after the request has been handled by the controller, but before the server responds to the client.
I have a policy use-case that requires the result of the request in order to answer the question; I'd like to run it on every request, so implementing in each controller handler isn't feasible.
The text was updated successfully, but these errors were encountered: