mirror of
https://github.com/gin-gonic/gin.git
synced 2025-10-17 14:12:16 +08:00
Merge bb2a73c9004201030a2be6af78319a096b3bb7b8 into 98af44604c755936c31d990f7135b34e1433095f
This commit is contained in:
commit
3bccfbc3dd
5
gin.go
5
gin.go
@ -78,6 +78,7 @@ type (
|
|||||||
// handler.
|
// handler.
|
||||||
HandleMethodNotAllowed bool
|
HandleMethodNotAllowed bool
|
||||||
ForwardedByClientIP bool
|
ForwardedByClientIP bool
|
||||||
|
UseRawPath bool
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -102,6 +103,7 @@ func New() *Engine {
|
|||||||
HandleMethodNotAllowed: false,
|
HandleMethodNotAllowed: false,
|
||||||
ForwardedByClientIP: true,
|
ForwardedByClientIP: true,
|
||||||
trees: make(methodTrees, 0, 9),
|
trees: make(methodTrees, 0, 9),
|
||||||
|
UseRawPath: false,
|
||||||
}
|
}
|
||||||
engine.RouterGroup.engine = engine
|
engine.RouterGroup.engine = engine
|
||||||
engine.pool.New = func() interface{} {
|
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) {
|
func (engine *Engine) handleHTTPRequest(context *Context) {
|
||||||
httpMethod := context.Request.Method
|
httpMethod := context.Request.Method
|
||||||
path := context.Request.URL.Path
|
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
|
// Find root of the tree for the given HTTP method
|
||||||
t := engine.trees
|
t := engine.trees
|
||||||
|
Loading…
x
Reference in New Issue
Block a user