From e481671814fb91299db7b501cc2520236f9514a8 Mon Sep 17 00:00:00 2001 From: astaxie Date: Thu, 19 Dec 2013 13:07:43 +0800 Subject: [PATCH] _method also must support user defined router --- router.go | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/router.go b/router.go index 7b79d3ec..a3dfaefb 100644 --- a/router.go +++ b/router.go @@ -790,27 +790,21 @@ func (p *ControllerRegistor) getErrorHandler(errorCode string) func(rw http.Resp func (p *ControllerRegistor) getRunMethod(method string, context *beecontext.Context, router *controllerInfo) string { method = strings.ToLower(method) + if method == "post" && strings.ToLower(context.Input.Query("_method")) == "put" { + method = "put" + } + if method == "post" && strings.ToLower(context.Input.Query("_method")) == "delete" { + method = "delete" + } if router.hasMethod { if m, ok := router.methods[method]; ok { return m } else if m, ok = router.methods["*"]; ok { return m } else { - if method == "POST" && strings.ToLower(context.Input.Query("_method")) == "put" { - return "Put" - } - if method == "POST" && strings.ToLower(context.Input.Query("_method")) == "delete" { - return "Delete" - } return strings.Title(method) } } else { - if method == "POST" && strings.ToLower(context.Input.Query("_method")) == "put" { - return "Put" - } - if method == "POST" && strings.ToLower(context.Input.Query("_method")) == "delete" { - return "Delete" - } return strings.Title(method) } }