Open vito-go opened 2 years ago
func main() {
gin.SetMode(gin.DebugMode)
engine := gin.Default()
f1 := func(ctx *gin.Context) {
ctx.JSON(200, "/:app/*a"+ctx.Request.URL.Path)
}
f2 := func(ctx *gin.Context) {
ctx.JSON(200, "/helloworld"+ctx.Request.URL.Path)
}
engine.GET("/:app/*a", f1)
engine.GET("/helloworld", f2)
engine.Run(":8989")
}
// all the request path like /*/* will execute f1 except that the path begin with `h`,
// e.g /haha/hi /hello/liushihao /hi/world
Is it a bug? Or why just match only the first letter h
?
[GIN-debug] Listening and serving HTTP on :8989
[GIN] 2022/01/20 - 15:30:41 | 404 | 832ns | 127.0.0.1 | GET "/hello/liushihao"
[GIN] 2022/01/20 - 15:30:51 | 404 | 918ns | 127.0.0.1 | GET "/hi/vito-go"
[GIN] 2022/01/20 - 15:30:59 | 200 | 35.791µs | 127.0.0.1 | GET "/gin/vito-go"
[GIN] 2022/01/20 - 15:31:08 | 200 | 21.047µs | 127.0.0.1 | GET "/helloworld"
Path /helloworld will only match /helloworld, so any path like // will match /:app/*a
Path /helloworld will only match /helloworld, so any path like // will match /:app/*a
I can not aggree with you. When the Path /helloworld
router exists, any path like /h/ will not match /:app/*a
Can you test it on v1.7.7
?
Why 404
Description
How to reproduce
Expectations
Environment
gin: v1.7.1 go version go1.17.5 linux/amd64