- With issues: The routing rules did not resolve as expected
Description
How to reproduce
package main
import (
"github.com/gin-gonic/gin"
"net/http"
)
func main() {
r := gin.Default()
apiV1 := r.Group("")
{
apiV1.GET("/:kind", func(c *gin.Context) {
c.JSON(http.StatusOK, gin.H{"message": "Get /:kind API"})
})
apiV1.GET("/:kind/:type", func(c *gin.Context) {
c.JSON(http.StatusOK, gin.H{"message": "Get /:kind/:type API"})
})
apiV1.GET("/namespaces/:type/:name", func(c *gin.Context) {
c.JSON(http.StatusOK, gin.H{"message": "Get /namespaces/:type/:name API"})
})
}
r.Run(":8080")
}
Expectations
curl http://localhost:8080/namespaces/type
I want to request /namespaces/type
and I expect it to match the /:kind/:type
route.
I actually get a 404 .
Is this behavior correct, or is it a bug?
Actual result
$ curl http://localhost:8080/namespaces/type
404 page not found
$ curl http://localhost:8080/namespaces
{"message":"Get /:kind API"}
Environment
- go version: go1.22.2
- gin version (or commit ref): v1.10.0
- operating system: windows