-
Notifications
You must be signed in to change notification settings - Fork 1.6k
En/http redirects #1640
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
base: development
Are you sure you want to change the base?
En/http redirects #1640
Conversation
@Umang01-hash , Can we also check and add tests for url with path and query params as well as request Bodies, headers etc.....get handled successfully through the redirect. I feel that is not the case right now. |
app.GET("/old-page", func(ctx *gofr.Context) (any, error) { | ||
// Redirect to a new URL with 301 Moved Permanently status | ||
return ctx.Redirect("/new-page", http.StatusMovedPermanently) | ||
}) | ||
|
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.
Let's not have a redirect method. We can just expose response of redirect Type ..... Also, we must ensure the traces are in hierarchy.
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 agree. Till now, all responses in Gofr are a type which is returned. ctx.Redirect is coming from other framework's behaviour where things like ctx.JSON etc are method. Also, we do not ask people to set manual status codes - but, we automatically decide. We should do the same and use a proper status code. The usecase in APIs for redirects are never going to be 301 - I think.
Pull Request Template
Description:
Example:
Additional Information:
Checklist:
goimport
andgolangci-lint
.Thank you for your contribution!