- With issues:
- Use the search tool before opening a new issue.
- Please provide source code and commit sha if you found a bug.
- Review existing issues and provide feedback or react to them.
Description
路由无法正确匹配
How to reproduce
package main
import (
"github.com/gin-gonic/gin"
)
func main() {
g := gin.Default()
g.POST("/mount/:mode/:env/:servers/:behavior/:begin_player_id/:end_player_id/:mount_delay/:monitor", func(c *gin.Context) {
c.String(200, "Hello1")
})
g.POST("/inspect/:mode/:env/:servers/:behavior/:player_id", func(c *gin.Context) {
c.String(200, "Hello2")
})
g.Run(":9000")
}
Expectations
$ curl -X POST http://localhost:9000/mount/linear/local/1/common/101/101/100/true
Hello1
Actual result
$ curl -X POST http://127.0.0.1:3344/mount/linear/local/1/common/101/101/100/true
Hello2
经常出现 Hello2 -> Frequently 偶尔出现 Hello1 -> Occasionally 将 "/inspect/:mode/:env/:servers/:behavior/:player_id" 修改为 "/inspect/local/:game_servers/:robot_behavior/:player_id" 则完全正确 modify "/inspect/:mode/:env/:servers/:behavior/:player_id" to "/inspect/local/:game_servers/:robot_behavior/:player_id" is ok
Environment
- go version: go1.23.1 darwin/arm64
- gin version (or commit ref): v1.9.1
- operating system: MacOS
Comment From: pscheid92
Hello @Mericusta. Sadly, I cannot reproduce the issue with your code snippet. For me, the expected behaviour happens all the time.
I realised your curl calls reach out to two different server addresses. Perhaps an error crept into your reproducible example snippets?
In the first example you call localhost:9000
in the second you call 127.0.0.1:3344
.