-
-
Notifications
You must be signed in to change notification settings - Fork 7.6k
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
feature(core): allow status override in interceptors #1901
feature(core): allow status override in interceptors #1901
Conversation
added unit test and integration test changes http adapter to not send http status in reply
Pull Request Test Coverage Report for Build 2204
💛 - Coveralls |
Pull Request Test Coverage Report for Build 2276
💛 - Coveralls |
What about setting And PS. thanks for your contribution! :) |
@kamilmysliwiec we could do that, but since It's hard to measure when we need to set it conditionally. And if an interceptor wants to read the current status it possible by doing it my way. Also if |
Your current solution is fine. I'm just saying that you can leave |
@kamilmysliwiec ahh like that ;) Of course will change it in a minute. One other thing what we could improve is also set the headers before running the interceptors? |
So I assume that you basically want to give an ability to override headers set through |
@kamilmysliwiec yes exactly ;), let me know if we want that, then I'll create a new pull request with this feature in it. |
Well, why not :) Sounds good! |
@kamilmysliwiec alright I've reverted the code so that the signature of reply didn't change only made the statusCode optional and check for it in the reply. Let me know if any other changes are needed. Also should I change the header feature in this pull request? Otherwise we get merge conflicts later on. |
@kamilmysliwiec is there any documentation that needs to be changes? |
You can push headers feature here too.
Very likely no :) |
…or testing header override.
@kamilmysliwiec I think there is something wrong with the travis config, cause at my pc it's running fine and all the tests pass. But somehow node 8 has troubles with typeorm? |
There is a sort of race condition that I have to fix shortly. No worries (triggering another build should help) |
@kamilmysliwiec how do I trigger an other build? :) |
No worries, I'll fix that! Great contribution, thanks @toonvanstrijp :) |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
Currently the only way to set a custom http status code is to use the @res() or @httpcode(). By default Nest is returning 200 or 201. Right now I'm trying to implement a interceptor that sets the status code but because Nest is overriding this in the reply phase it's not possible to set it. Or yeah it is but Nest overrides it.
Issue Number: #1869
What is the new behavior?
I've replaces the code where nest is setting the HttpStatus, this way the status is set before nest is running trough all the interceptors. Because of this we now can override the status by doing
res.status(404)
or we could read the current status by doing:res.statusCode
.Does this PR introduce a breaking change?
Other information