mirror of https://github.com/gin-gonic/gin.git
parent
545101811a
commit
6c8c90115d
|
@ -85,13 +85,15 @@ func main() {
|
|||
func main() {
|
||||
r := gin.Default()
|
||||
|
||||
// This handler will match /user/john but will not match neither /user/ or /user
|
||||
r.GET("/user/:name", func(c *gin.Context) {
|
||||
name := c.Params.ByName("name")
|
||||
message := "Hello "+name
|
||||
c.String(200, message)
|
||||
})
|
||||
|
||||
r.GET("/user/:name/:action", func(c *gin.Context) {
|
||||
// However, this one will match /user/john and also /user/john/send
|
||||
r.GET("/user/:name/*action", func(c *gin.Context) {
|
||||
name := c.Params.ByName("name")
|
||||
action := c.Params.ByName("action")
|
||||
message := name + " is " + action
|
||||
|
|
Loading…
Reference in New Issue