Add mixed param and non-param paths (port of httprouter#329) (#2663)

Co-authored-by: Bo-Yi Wu <appleboy.tw@gmail.com>
This commit is contained in:
Ross Wolf
2021-04-05 20:49:08 -06:00
committed by GitHub
parent a331dc6a31
commit f3de8132c5
5 changed files with 112 additions and 68 deletions
+7
View File
@@ -243,6 +243,13 @@ func main() {
c.FullPath() == "/user/:name/*action" // true
})
// This handler will add a new router for /user/groups.
// Exact routes are resolved before param routes, regardless of the order they were defined.
// Routes starting with /user/groups are never interpreted as /user/:name/... routes
router.GET("/user/groups", func(c *gin.Context) {
c.String(http.StatusOK, "The available groups are [...]", name)
})
router.Run(":8080")
}
```