From 6c8c90115d513f4b008f04dcc9aae4c8ffe0bff3 Mon Sep 17 00:00:00 2001 From: Javier Provecho Date: Tue, 8 Jul 2014 11:55:20 +0200 Subject: [PATCH] Update README.md Example of Catch-All parameters. --- README.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index acba80f3..63c67e84 100644 --- a/README.md +++ b/README.md @@ -84,20 +84,22 @@ func main() { ```go 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 c.String(200, message) }) - + // Listen and server on 0.0.0.0:8080 r.Run(":8080") }