clearly the router, If user set the third params, will not follow the RESTful method
Showing
1 changed file
with
12 additions
and
8 deletions
| ... | @@ -566,10 +566,12 @@ func (p *ControllerRegistor) ServeHTTP(rw http.ResponseWriter, r *http.Request) | ... | @@ -566,10 +566,12 @@ 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 | runrouter = route.controllerType | ||
| 570 | findrouter = true | ||
| 571 | runMethod = p.getRunMethod(r.Method, context, route) | 569 | runMethod = p.getRunMethod(r.Method, context, route) |
| 572 | break | 570 | if runMethod != "" { |
| 571 | runrouter = route.controllerType | ||
| 572 | findrouter = true | ||
| 573 | break | ||
| 574 | } | ||
| 573 | } | 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 |
| ... | @@ -608,11 +610,13 @@ func (p *ControllerRegistor) ServeHTTP(rw http.ResponseWriter, r *http.Request) | ... | @@ -608,11 +610,13 @@ 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 | } |
| 611 | runrouter = route.controllerType | ||
| 612 | findrouter = true | ||
| 613 | context.Input.Params = params | ||
| 614 | runMethod = p.getRunMethod(r.Method, context, route) | 613 | runMethod = p.getRunMethod(r.Method, context, route) |
| 615 | break | 614 | if runMethod != "" { |
| 615 | runrouter = route.controllerType | ||
| 616 | context.Input.Params = params | ||
| 617 | findrouter = true | ||
| 618 | break | ||
| 619 | } | ||
| 616 | } | 620 | } |
| 617 | } | 621 | } |
| 618 | 622 | ||
| ... | @@ -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