func getHandler(c *echo.Context) error {
return c.String("Hello world")
}
func postHandler(c *echo.Context) error {
return echo.Redirect(http.StatusTemporaryRedirect, "/")
}
func main() {
e := echo.New()
e.Get("/", getHandler)
e.Post("/post", postHandler)
e.Run(":8080")
}
I whipped up that example pretty quickly, so I'm not entirely sure it works PERFECT, but the case that it makes hold true. For situations where you would want to redirect from a POST to a GET (for example, POST to a login form, and then redirect them back to the index), echo.Redirect fails. The redirect actually redirects to POST / instead of the expected GET /
I found some resources regarding this in Go that were solved in 2012, but has been resolved for some time. I'm assuming this might be within echo instead of Go's HTTP layer directly.
I whipped up that example pretty quickly, so I'm not entirely sure it works PERFECT, but the case that it makes hold true. For situations where you would want to redirect from a POST to a GET (for example, POST to a login form, and then redirect them back to the index),
echo.Redirectfails. The redirect actually redirects toPOST /instead of the expectedGET /I found some resources regarding this in Go that were solved in 2012, but has been resolved for some time. I'm assuming this might be within echo instead of Go's HTTP layer directly.