-
Notifications
You must be signed in to change notification settings - Fork 8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug]mixed param and non-param paths #2786
Comments
@waising router.GET("/api/v1/:param", func(c *gin.Context) {
if c.Param("param") == "abc" {
// do something for typical param
}
// normal case ...
}) |
same mistake as #2762 |
I wouldn't say it's a "mistake". Isn't this exactly the problem that was supposed to be fixed by the new router? |
@qm012 I can reproduce the issue with the latest commit d4ca9a0 package main
import (
"fmt"
"github.com/gin-gonic/gin"
)
func handler01(c *gin.Context) {
fmt.Println(c.Params)
c.String(200, "ok01")
}
func handler02(c *gin.Context) {
fmt.Println(c.Params)
c.String(200, "ok02")
}
func main() {
g := gin.Default()
g.GET("/get/abc", handler01)
g.GET("/get/:param", handler02)
g.Run(":9090")
} result: /abc 200 ok02
/a 404
/ab 200 ok02
/xyz 200 ok02
/abcd 200 ok02 |
@appleboy Please give me some time. I am trying to solve this problem. There is no problem with the first-level route match, but if the multi-level route is greater than or less than the current path, it will not match the original one |
@qm012 Thanks. @waising @zihengCat We move to #2796 for discussion in the fueture. |
* update match rule * add comments (cherry picked from commit 0a55865)
* update match rule * add comments (cherry picked from commit 0a55865)
* update match rule * add comments
gin version 1.7.2
"/get/abc" = value1
"/get/:param" = value2
GET /get/abc => value1
GET /get/a => value2
GET /get/xyz => value2
GET /get/abcd => 404 (should be value2)
The text was updated successfully, but these errors were encountered: