func main() {
router := gin.Default()
// This handler will match /user/john but will not match /user/ or /user
//router.GET("/user/:name", func(c *gin.Context) {
// name := c.Param("name")
// c.String(http.StatusOK, "Hello %s", name)
//})
// However, this one will match /user/john/ and also /user/john/send
// If no other routers match /user/john, it will redirect to /user/john/
router.GET("/user/:name/*action", func(c *gin.Context) {
name := c.Param("name")
action := c.Param("action")
message := name + " is " + action
c.String(http.StatusOK, message)
})
router.Run(":8080")
}
when i annotate router.GET("/user/:name"
, is it mean that no other routers match /user/john? However, when i accessed the/user/john, it did not redirect to /user/john/.
Comment From: thinkerou
it's different :name
and *action
.
Comment From: wzhiyog
it's different
:name
and*action
.
what's mean?