clearly the router, If user set the third params, will not follow the RESTful method
Showing
1 changed file
with
8 additions
and
4 deletions
| ... | @@ -566,11 +566,13 @@ func (p *ControllerRegistor) ServeHTTP(rw http.ResponseWriter, r *http.Request) | ... | @@ -566,11 +566,13 @@ func (p *ControllerRegistor) ServeHTTP(rw http.ResponseWriter, r *http.Request) |
| 566 | for _, route := range p.fixrouters { | 566 | for _, route := range p.fixrouters { |
| 567 | n := len(requestPath) | 567 | n := len(requestPath) |
| 568 | if requestPath == route.pattern { | 568 | if requestPath == route.pattern { |
| 569 | runMethod = p.getRunMethod(r.Method, context, route) | ||
| 570 | if runMethod != "" { | ||
| 569 | runrouter = route.controllerType | 571 | runrouter = route.controllerType |
| 570 | findrouter = true | 572 | findrouter = true |
| 571 | runMethod = p.getRunMethod(r.Method, context, route) | ||
| 572 | break | 573 | break |
| 573 | } | 574 | } |
| 575 | } | ||
| 574 | // pattern /admin url /admin 200 /admin/ 404 | 576 | // pattern /admin url /admin 200 /admin/ 404 |
| 575 | // pattern /admin/ url /admin 301 /admin/ 200 | 577 | // pattern /admin/ url /admin 301 /admin/ 200 |
| 576 | if requestPath[n-1] != '/' && len(route.pattern) == n+1 && | 578 | if requestPath[n-1] != '/' && len(route.pattern) == n+1 && |
| ... | @@ -608,13 +610,15 @@ func (p *ControllerRegistor) ServeHTTP(rw http.ResponseWriter, r *http.Request) | ... | @@ -608,13 +610,15 @@ func (p *ControllerRegistor) ServeHTTP(rw http.ResponseWriter, r *http.Request) |
| 608 | //reassemble query params and add to RawQuery | 610 | //reassemble query params and add to RawQuery |
| 609 | r.URL.RawQuery = url.Values(values).Encode() | 611 | r.URL.RawQuery = url.Values(values).Encode() |
| 610 | } | 612 | } |
| 613 | runMethod = p.getRunMethod(r.Method, context, route) | ||
| 614 | if runMethod != "" { | ||
| 611 | runrouter = route.controllerType | 615 | runrouter = route.controllerType |
| 612 | findrouter = true | ||
| 613 | context.Input.Params = params | 616 | context.Input.Params = params |
| 614 | runMethod = p.getRunMethod(r.Method, context, route) | 617 | findrouter = true |
| 615 | break | 618 | break |
| 616 | } | 619 | } |
| 617 | } | 620 | } |
| 621 | } | ||
| 618 | 622 | ||
| 619 | if !findrouter && p.enableAuto { | 623 | if !findrouter && p.enableAuto { |
| 620 | // deal with url with diffirent ext | 624 | // deal with url with diffirent ext |
| ... | @@ -798,7 +802,7 @@ func (p *ControllerRegistor) getRunMethod(method string, context *beecontext.Con | ... | @@ -798,7 +802,7 @@ func (p *ControllerRegistor) getRunMethod(method string, context *beecontext.Con |
| 798 | } else if m, ok = router.methods["*"]; ok { | 802 | } else if m, ok = router.methods["*"]; ok { |
| 799 | return m | 803 | return m |
| 800 | } else { | 804 | } else { |
| 801 | return strings.Title(method) | 805 | return "" |
| 802 | } | 806 | } |
| 803 | } else { | 807 | } else { |
| 804 | return strings.Title(method) | 808 | return strings.Title(method) | ... | ... |
-
Please register or sign in to post a comment