24489df6 by astaxie

Merge pull request #867 from WithGJR/develop

fix router bug: when the request is PUT or DELETE, router can't find the...
2 parents fb8e9ae1 efc14a1e
Showing 1 changed file with 11 additions and 1 deletions
...@@ -648,7 +648,17 @@ func (p *ControllerRegistor) ServeHTTP(rw http.ResponseWriter, r *http.Request) ...@@ -648,7 +648,17 @@ func (p *ControllerRegistor) ServeHTTP(rw http.ResponseWriter, r *http.Request)
648 } 648 }
649 649
650 if !findrouter { 650 if !findrouter {
651 if t, ok := p.routers[r.Method]; ok { 651 http_method := r.Method
652
653 if http_method == "POST" && context.Input.Query("_method") == "PUT" {
654 http_method = "PUT"
655 }
656
657 if http_method == "POST" && context.Input.Query("_method") == "DELETE" {
658 http_method = "DELETE"
659 }
660
661 if t, ok := p.routers[http_method]; ok {
652 runObject, p := t.Match(urlPath) 662 runObject, p := t.Match(urlPath)
653 if r, ok := runObject.(*controllerInfo); ok { 663 if r, ok := runObject.(*controllerInfo); ok {
654 routerInfo = r 664 routerInfo = r
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!