mirror of
https://github.com/astaxie/beego.git
synced 2024-11-22 20:10:55 +00:00
improve the performance
This commit is contained in:
parent
ea9c2cebfd
commit
e7f08946d1
10
router.go
10
router.go
@ -327,8 +327,6 @@ func (p *ControllerRegistor) ServeHTTP(rw http.ResponseWriter, r *http.Request)
|
|||||||
context.Input.Body()
|
context.Input.Body()
|
||||||
}
|
}
|
||||||
|
|
||||||
r.ParseMultipartForm(MaxMemory)
|
|
||||||
|
|
||||||
//first find path from the fixrouters to Improve Performance
|
//first find path from the fixrouters to Improve Performance
|
||||||
for _, route := range p.fixrouters {
|
for _, route := range p.fixrouters {
|
||||||
n := len(requestPath)
|
n := len(requestPath)
|
||||||
@ -369,12 +367,10 @@ func (p *ControllerRegistor) ServeHTTP(rw http.ResponseWriter, r *http.Request)
|
|||||||
values := r.URL.Query()
|
values := r.URL.Query()
|
||||||
for i, match := range matches[1:] {
|
for i, match := range matches[1:] {
|
||||||
values.Add(route.params[i], match)
|
values.Add(route.params[i], match)
|
||||||
r.Form.Add(route.params[i], match)
|
|
||||||
params[route.params[i]] = match
|
params[route.params[i]] = match
|
||||||
}
|
}
|
||||||
//reassemble query params and add to RawQuery
|
//reassemble query params and add to RawQuery
|
||||||
r.URL.RawQuery = url.Values(values).Encode()
|
r.URL.RawQuery = url.Values(values).Encode()
|
||||||
//r.URL.RawQuery = url.Values(values).Encode()
|
|
||||||
}
|
}
|
||||||
runrouter = route
|
runrouter = route
|
||||||
findrouter = true
|
findrouter = true
|
||||||
@ -383,6 +379,9 @@ func (p *ControllerRegistor) ServeHTTP(rw http.ResponseWriter, r *http.Request)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if runrouter != nil {
|
if runrouter != nil {
|
||||||
|
if r.Method == "POST" {
|
||||||
|
r.ParseMultipartForm(MaxMemory)
|
||||||
|
}
|
||||||
//execute middleware filters
|
//execute middleware filters
|
||||||
if p.enableFilter {
|
if p.enableFilter {
|
||||||
if l, ok := p.filters["BeforExec"]; ok {
|
if l, ok := p.filters["BeforExec"]; ok {
|
||||||
@ -563,6 +562,9 @@ func (p *ControllerRegistor) ServeHTTP(rw http.ResponseWriter, r *http.Request)
|
|||||||
if strings.HasPrefix(strings.ToLower(requestPath), "/"+cName+"/") {
|
if strings.HasPrefix(strings.ToLower(requestPath), "/"+cName+"/") {
|
||||||
for mName, controllerType := range methodmap {
|
for mName, controllerType := range methodmap {
|
||||||
if strings.HasPrefix(strings.ToLower(requestPath), "/"+cName+"/"+strings.ToLower(mName)) {
|
if strings.HasPrefix(strings.ToLower(requestPath), "/"+cName+"/"+strings.ToLower(mName)) {
|
||||||
|
if r.Method == "POST" {
|
||||||
|
r.ParseMultipartForm(MaxMemory)
|
||||||
|
}
|
||||||
//execute middleware filters
|
//execute middleware filters
|
||||||
if p.enableFilter {
|
if p.enableFilter {
|
||||||
if l, ok := p.filters["BeforExec"]; ok {
|
if l, ok := p.filters["BeforExec"]; ok {
|
||||||
|
Loading…
Reference in New Issue
Block a user