Closed
Description
I've made a sample code to explain what's happening:
package main
import (
"net/http"
"github.com/gin-gonic/gin"
)
func main() {
r := gin.Default()
r.RedirectTrailingSlash = true
r.RedirectFixedPath = true
r.GET("/login", func(c *gin.Context) {
form := "<form method='POST' action='/login/do'><input type='submit' /></form>"
c.Header("Content-Type", "text/html")
c.String(http.StatusOK, form)
})
r.POST("/login/do", func(c *gin.Context) {
c.Redirect(http.StatusTemporaryRedirect, "/welcome")
})
r.GET("/welcome", func(c *gin.Context) {
c.String(http.StatusOK, "Welcome")
})
r.Run(":8888")
}
When it tries to redirect from a POST to /login/do
to /welcome
the result is 404 (404 page not found
).
But if I try to go directly to /welcome
everything works fine.
Am I doing something wrong?
Metadata
Metadata
Assignees
Labels
No labels