From 7a8ad522fca7afd02b64f855a28983ec28974597 Mon Sep 17 00:00:00 2001 From: zhoujun Date: Thu, 25 Oct 2018 11:39:12 +0800 Subject: [PATCH] Update README.md --- README.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/README.md b/README.md index 1b5fb493..6a4edc79 100644 --- a/README.md +++ b/README.md @@ -61,6 +61,7 @@ Gin is a web framework written in Go (Golang). It features a martini-like API wi - [http2 server push](#http2-server-push) - [Define format for the log of routes](#define-format-for-the-log-of-routes) - [Set and get a cookie](#set-and-get-a-cookie) + - [Route in context](#route-in-context) - [Testing](#testing) - [Users](#users) @@ -1910,6 +1911,26 @@ func main() { } ``` +### Route in context + +```go +package main + +import ( + "log" + + "github.com/gin-gonic/gin" +) + +func main() { + router := gin.Default() + router.GET("/user/:id", func(c *gin.Context) { + log.Println(c.Route) // /user/:id + log.Println(c.Request.URL.Path) // /user/abc + }) + router.Run() +} +``` ## Testing