mirror of
https://github.com/gin-gonic/gin.git
synced 2025-10-16 05:16:35 +08:00
I added a Boolean to the that if set to true, extracts the RawPath from the URL.
This commit is contained in:
parent
f931d1ea80
commit
bb2a73c900
5
gin.go
5
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
|
||||
|
Loading…
x
Reference in New Issue
Block a user