Merge 0f10af724607671221bd3ecf1fe3f77815faf3d0 into c8b35d34452e9c1fc34d0aec480d6fa7e3092584

This commit is contained in:
Jace Shim 2016-12-05 10:18:17 +00:00 committed by GitHub
commit a1274f8ab4
2 changed files with 14 additions and 0 deletions

6
.idea/vcs.xml generated Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>

8
gin.go
View File

@ -78,6 +78,9 @@ type (
// handler.
HandleMethodNotAllowed bool
ForwardedByClientIP bool
// If enabled, the path using RawPath in net.url.URL.RawPath
// RawPath dose not decode path.
UseRawPath bool
}
)
@ -102,6 +105,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 +274,10 @@ 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