_method also must support user defined router
Showing
1 changed file
with
6 additions
and
12 deletions
| ... | @@ -790,27 +790,21 @@ func (p *ControllerRegistor) getErrorHandler(errorCode string) func(rw http.Resp | ... | @@ -790,27 +790,21 @@ func (p *ControllerRegistor) getErrorHandler(errorCode string) func(rw http.Resp |
| 790 | 790 | ||
| 791 | func (p *ControllerRegistor) getRunMethod(method string, context *beecontext.Context, router *controllerInfo) string { | 791 | func (p *ControllerRegistor) getRunMethod(method string, context *beecontext.Context, router *controllerInfo) string { |
| 792 | method = strings.ToLower(method) | 792 | method = strings.ToLower(method) |
| 793 | if method == "post" && strings.ToLower(context.Input.Query("_method")) == "put" { | ||
| 794 | method = "put" | ||
| 795 | } | ||
| 796 | if method == "post" && strings.ToLower(context.Input.Query("_method")) == "delete" { | ||
| 797 | method = "delete" | ||
| 798 | } | ||
| 793 | if router.hasMethod { | 799 | if router.hasMethod { |
| 794 | if m, ok := router.methods[method]; ok { | 800 | if m, ok := router.methods[method]; ok { |
| 795 | return m | 801 | return m |
| 796 | } else if m, ok = router.methods["*"]; ok { | 802 | } else if m, ok = router.methods["*"]; ok { |
| 797 | return m | 803 | return m |
| 798 | } else { | 804 | } else { |
| 799 | if method == "POST" && strings.ToLower(context.Input.Query("_method")) == "put" { | ||
| 800 | return "Put" | ||
| 801 | } | ||
| 802 | if method == "POST" && strings.ToLower(context.Input.Query("_method")) == "delete" { | ||
| 803 | return "Delete" | ||
| 804 | } | ||
| 805 | return strings.Title(method) | 805 | return strings.Title(method) |
| 806 | } | 806 | } |
| 807 | } else { | 807 | } else { |
| 808 | if method == "POST" && strings.ToLower(context.Input.Query("_method")) == "put" { | ||
| 809 | return "Put" | ||
| 810 | } | ||
| 811 | if method == "POST" && strings.ToLower(context.Input.Query("_method")) == "delete" { | ||
| 812 | return "Delete" | ||
| 813 | } | ||
| 814 | return strings.Title(method) | 808 | return strings.Title(method) |
| 815 | } | 809 | } |
| 816 | } | 810 | } | ... | ... |
-
Please register or sign in to post a comment