From bb2a73c9004201030a2be6af78319a096b3bb7b8 Mon Sep 17 00:00:00 2001 From: jaceshim Date: Thu, 9 Jun 2016 17:28:36 +0900 Subject: [PATCH] I added a Boolean to the that if set to true, extracts the RawPath from the URL. --- gin.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/gin.go b/gin.go index 60f4ab29..cf3130ac 100644 --- a/gin.go +++ b/gin.go @@ -78,6 +78,7 @@ type ( // handler. HandleMethodNotAllowed bool ForwardedByClientIP bool + UseRawPath bool } ) @@ -102,6 +103,7 @@ func New() *Engine { HandleMethodNotAllowed: false, ForwardedByClientIP: true, trees: make(methodTrees, 0, 9), + UseRawPath: false, } engine.RouterGroup.engine = engine engine.pool.New = func() interface{} { @@ -270,6 +272,9 @@ func (engine *Engine) ServeHTTP(w http.ResponseWriter, req *http.Request) { func (engine *Engine) handleHTTPRequest(context *Context) { httpMethod := context.Request.Method path := context.Request.URL.Path + if (engine.UseRawPath && len(context.Request.URL.RawPath) > 0 ) { + path = context.Request.URL.RawPath + } // Find root of the tree for the given HTTP method t := engine.trees