1
0
mirror of https://github.com/astaxie/beego.git synced 2024-11-26 08:31:28 +00:00

Merge pull request #867 from WithGJR/develop

fix router bug: when the request is PUT or DELETE, router can't find the...
This commit is contained in:
astaxie 2014-10-16 23:07:20 +08:00
commit 24489df63d

View File

@ -648,7 +648,17 @@ func (p *ControllerRegistor) ServeHTTP(rw http.ResponseWriter, r *http.Request)
} }
if !findrouter { if !findrouter {
if t, ok := p.routers[r.Method]; ok { http_method := r.Method
if http_method == "POST" && context.Input.Query("_method") == "PUT" {
http_method = "PUT"
}
if http_method == "POST" && context.Input.Query("_method") == "DELETE" {
http_method = "DELETE"
}
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 {
routerInfo = r routerInfo = r