gofr
gofr copied to clipboard
En/http redirects
Pull Request Template
Description:
- Resolves #1531
Example:
package main
import (
"gofr.dev/pkg/gofr"
"gofr.dev/pkg/gofr/http/response"
)
func main() {
app := gofr.New()
app.GET("/old-page", func(ctx *gofr.Context) (any, error) {
// Redirect to a new URL
return response.Redirect{URL: "https://example.com/new-page"}, nil
})
app.Run()
}
Additional Information:
- Mention any relevant dependencies or external libraries used.
- Include screenshots or code snippets (if necessary) to clarify the changes.
Checklist:
- [x] I have formatted my code using
goimportandgolangci-lint. - [x] All new code is covered by unit tests.
- [x] This PR does not decrease the overall code coverage.
- [x] I have reviewed the code comments and documentation for clarity.
Thank you for your contribution!
@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.
@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.
@Umang01-hash, Can we add test for these cases ? I feel this implementation can fall short in fitting these usecases.