-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Closed
Description
Feature Description
At the moment, there're 3 methods to redirect: Redirect(), RedirectToRoute(), RedirectBack(). They're useful methods but they make Ctx more mess. To solve this, we should combine them into the one main method as Redirect()
Also, we can add flash messages to make redirection more efficent like Laravel: https://laravel.com/docs/9.x/redirects#redirecting-with-flashed-session-data.
Additional Context (optional)
This feature is also similar to @sujit-baniya's https://github.com/sujit-baniya/flash package.
Code Snippet (optional)
package main
import "github.com/gofiber/fiber/v2"
import "log"
func main() {
app := fiber.New()
app.Get("/test", func(c fiber.Ctx) {
// Simple methods
c.Redirect().To("https://google.com")
c.Redirect().Route("homepage")
c.Redirect().Back()
// With flash messages
c.Redirect().WithSuccess("test", "test2", "...").Route("homepage")
c.Redirect().WithError("test", "test2", "...").Route("homepage")
c.Redirect().With("message", "There's an unknown error!").Back()
// may be a method to set status?
c.Redirect().Status(302).Route("index")
})
log.Fatal(app.Listen(":3000"))
}Checklist:
- I agree to follow Fiber's Code of Conduct.
- I have checked for existing issues that describe my suggestion prior to opening this one.
- I understand that improperly formatted feature requests may be closed without explanation.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
Done