Update README.md (#2804)

1. c.FullPath() == "/user/:name/*action"
get following error:
evaluated but not used 
2. c.String(http.StatusOK, "The available groups are [...]", name)
get following error:
undefined: name
This commit is contained in:
goqihoo 2021-08-11 09:42:25 +08:00 committed by GitHub
parent 6ebb945bd7
commit b463b1c2a1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 2 deletions

View File

@ -256,14 +256,15 @@ func main() {
// For each matched request Context will hold the route definition // For each matched request Context will hold the route definition
router.POST("/user/:name/*action", func(c *gin.Context) { router.POST("/user/:name/*action", func(c *gin.Context) {
c.FullPath() == "/user/:name/*action" // true b := c.FullPath() == "/user/:name/*action" // true
c.String(http.StatusOK, "%t", b)
}) })
// This handler will add a new router for /user/groups. // This handler will add a new router for /user/groups.
// Exact routes are resolved before param routes, regardless of the order they were defined. // 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 // Routes starting with /user/groups are never interpreted as /user/:name/... routes
router.GET("/user/groups", func(c *gin.Context) { router.GET("/user/groups", func(c *gin.Context) {
c.String(http.StatusOK, "The available groups are [...]", name) c.String(http.StatusOK, "The available groups are [...]")
}) })
router.Run(":8080") router.Run(":8080")