1
0
mirror of https://github.com/astaxie/beego.git synced 2024-11-22 14:00:54 +00:00

fix router bug with more better way

This commit is contained in:
WithGJR 2014-10-16 18:58:12 +08:00
parent fa1281002e
commit efc14a1e8d

View File

@ -648,20 +648,16 @@ func (p *ControllerRegistor) ServeHTTP(rw http.ResponseWriter, r *http.Request)
} }
if !findrouter { if !findrouter {
http_method := "" http_method := r.Method
if r.Method == "POST" && context.Input.Query("_method") == "PUT" { if http_method == "POST" && context.Input.Query("_method") == "PUT" {
http_method = "PUT" http_method = "PUT"
} }
if r.Method == "POST" && context.Input.Query("_method") == "DELETE" { if http_method == "POST" && context.Input.Query("_method") == "DELETE" {
http_method = "DELETE" http_method = "DELETE"
} }
if http_method != "PUT" && http_method != "DELETE" {
http_method = r.Method
}
if t, ok := p.routers[http_method]; ok { if t, ok := p.routers[http_method]; ok {
runObject, p := t.Match(urlPath) runObject, p := t.Match(urlPath)
if r, ok := runObject.(*controllerInfo); ok { if r, ok := runObject.(*controllerInfo); ok {