mirror of
https://github.com/gin-gonic/gin.git
synced 2025-10-16 21:32:11 +08:00
Merge 0f10af724607671221bd3ecf1fe3f77815faf3d0 into c8b35d34452e9c1fc34d0aec480d6fa7e3092584
This commit is contained in:
commit
a1274f8ab4
6
.idea/vcs.xml
generated
Normal file
6
.idea/vcs.xml
generated
Normal 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
8
gin.go
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user