efc14a1e by WithGJR

fix router bug with more better way

1 parent fa128100
...@@ -648,20 +648,16 @@ func (p *ControllerRegistor) ServeHTTP(rw http.ResponseWriter, r *http.Request) ...@@ -648,20 +648,16 @@ func (p *ControllerRegistor) ServeHTTP(rw http.ResponseWriter, r *http.Request)
648 } 648 }
649 649
650 if !findrouter { 650 if !findrouter {
651 http_method := "" 651 http_method := r.Method
652 652
653 if r.Method == "POST" && context.Input.Query("_method") == "PUT" { 653 if http_method == "POST" && context.Input.Query("_method") == "PUT" {
654 http_method = "PUT" 654 http_method = "PUT"
655 } 655 }
656 656
657 if r.Method == "POST" && context.Input.Query("_method") == "DELETE" { 657 if http_method == "POST" && context.Input.Query("_method") == "DELETE" {
658 http_method = "DELETE" 658 http_method = "DELETE"
659 } 659 }
660 660
661 if http_method != "PUT" && http_method != "DELETE" {
662 http_method = r.Method
663 }
664
665 if t, ok := p.routers[http_method]; ok { 661 if t, ok := p.routers[http_method]; ok {
666 runObject, p := t.Match(urlPath) 662 runObject, p := t.Match(urlPath)
667 if r, ok := runObject.(*controllerInfo); ok { 663 if r, ok := runObject.(*controllerInfo); ok {
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!