-
-
Notifications
You must be signed in to change notification settings - Fork 7.5k
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(redirect decorator) add redirect decorator #2632
feature(redirect decorator) add redirect decorator #2632
Conversation
Hey @johnbiundo! Thanks for the contribution. Could you somehow get rid of formatting changes? (Maybe run |
@kamilmysliwiec fixed the formatting changes (I hope! 😄 ) |
de35459
to
efa434a
Compare
Pull Request Test Coverage Report for Build 4136
💛 - Coveralls |
@@ -49,6 +49,11 @@ export class FastifyAdapter extends AbstractHttpAdapter { | |||
return response.view(view, options); | |||
} | |||
|
|||
public redirect(response: any, statusCode: number, url: string) { | |||
const code = statusCode ? statusCode : HttpStatus.TEMPORARY_REDIRECT; |
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.
Why do we presume that TEMPORARY_REDIRECT
should be the default one?
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.
@kamilmysliwiec Good catch. Both Express and Fastify default to 302 (FOUND). I always associated 302 with TEMPORARY_REDIRECT
but to send a 302, it should be FOUND
. Make sense?
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.
Make sense now :)
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.
OK, I will switch to 302 (FOUND) and resubmit.
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.
@kamilmysliwiec Switched to 302 found, as discussed.
efa434a
to
f4d3c03
Compare
Thanks @johnbiundo! I pushed small performance improvements & merged PR to 6.6.0 branch. Could you create a PR for docs to cover this feature :)? |
@kamilmysliwiec Will do! |
@kamilmysliwiec Docs PR submitted. |
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:
No docs yet
PR Type
What kind of change does this PR introduce?
Exposes
@Redirect()
decoratorRedirects to the specified
url
If no
statusCode
, sendsTEMPORARY_REDIRECT
(307)Method can return an object like
{ statusCode: 302, url: 'http://nestjs.com' }
which will override the decorator parameters.
[ ] Bugfix
[X] Feature
[ ] Code style update (formatting, local variables)
[ ] Refactoring (no functional changes, no api changes)
[ ] Build related changes
[ ] CI related changes
[ ] Other... Please describe:
[ ] Yes
[X] No