improve the performance
Showing
1 changed file
with
6 additions
and
4 deletions
| ... | @@ -327,8 +327,6 @@ func (p *ControllerRegistor) ServeHTTP(rw http.ResponseWriter, r *http.Request) | ... | @@ -327,8 +327,6 @@ func (p *ControllerRegistor) ServeHTTP(rw http.ResponseWriter, r *http.Request) |
| 327 | context.Input.Body() | 327 | context.Input.Body() |
| 328 | } | 328 | } |
| 329 | 329 | ||
| 330 | r.ParseMultipartForm(MaxMemory) | ||
| 331 | |||
| 332 | //first find path from the fixrouters to Improve Performance | 330 | //first find path from the fixrouters to Improve Performance |
| 333 | for _, route := range p.fixrouters { | 331 | for _, route := range p.fixrouters { |
| 334 | n := len(requestPath) | 332 | n := len(requestPath) |
| ... | @@ -369,12 +367,10 @@ func (p *ControllerRegistor) ServeHTTP(rw http.ResponseWriter, r *http.Request) | ... | @@ -369,12 +367,10 @@ func (p *ControllerRegistor) ServeHTTP(rw http.ResponseWriter, r *http.Request) |
| 369 | values := r.URL.Query() | 367 | values := r.URL.Query() |
| 370 | for i, match := range matches[1:] { | 368 | for i, match := range matches[1:] { |
| 371 | values.Add(route.params[i], match) | 369 | values.Add(route.params[i], match) |
| 372 | r.Form.Add(route.params[i], match) | ||
| 373 | params[route.params[i]] = match | 370 | params[route.params[i]] = match |
| 374 | } | 371 | } |
| 375 | //reassemble query params and add to RawQuery | 372 | //reassemble query params and add to RawQuery |
| 376 | r.URL.RawQuery = url.Values(values).Encode() | 373 | r.URL.RawQuery = url.Values(values).Encode() |
| 377 | //r.URL.RawQuery = url.Values(values).Encode() | ||
| 378 | } | 374 | } |
| 379 | runrouter = route | 375 | runrouter = route |
| 380 | findrouter = true | 376 | findrouter = true |
| ... | @@ -383,6 +379,9 @@ func (p *ControllerRegistor) ServeHTTP(rw http.ResponseWriter, r *http.Request) | ... | @@ -383,6 +379,9 @@ func (p *ControllerRegistor) ServeHTTP(rw http.ResponseWriter, r *http.Request) |
| 383 | } | 379 | } |
| 384 | 380 | ||
| 385 | if runrouter != nil { | 381 | if runrouter != nil { |
| 382 | if r.Method == "POST" { | ||
| 383 | r.ParseMultipartForm(MaxMemory) | ||
| 384 | } | ||
| 386 | //execute middleware filters | 385 | //execute middleware filters |
| 387 | if p.enableFilter { | 386 | if p.enableFilter { |
| 388 | if l, ok := p.filters["BeforExec"]; ok { | 387 | if l, ok := p.filters["BeforExec"]; ok { |
| ... | @@ -563,6 +562,9 @@ func (p *ControllerRegistor) ServeHTTP(rw http.ResponseWriter, r *http.Request) | ... | @@ -563,6 +562,9 @@ func (p *ControllerRegistor) ServeHTTP(rw http.ResponseWriter, r *http.Request) |
| 563 | if strings.HasPrefix(strings.ToLower(requestPath), "/"+cName+"/") { | 562 | if strings.HasPrefix(strings.ToLower(requestPath), "/"+cName+"/") { |
| 564 | for mName, controllerType := range methodmap { | 563 | for mName, controllerType := range methodmap { |
| 565 | if strings.HasPrefix(strings.ToLower(requestPath), "/"+cName+"/"+strings.ToLower(mName)) { | 564 | if strings.HasPrefix(strings.ToLower(requestPath), "/"+cName+"/"+strings.ToLower(mName)) { |
| 565 | if r.Method == "POST" { | ||
| 566 | r.ParseMultipartForm(MaxMemory) | ||
| 567 | } | ||
| 566 | //execute middleware filters | 568 | //execute middleware filters |
| 567 | if p.enableFilter { | 569 | if p.enableFilter { |
| 568 | if l, ok := p.filters["BeforExec"]; ok { | 570 | if l, ok := p.filters["BeforExec"]; ok { | ... | ... |
-
Please register or sign in to post a comment