53b2a29b by astaxie

when method is POST then to parse form

1 parent cb49be78
...@@ -575,7 +575,7 @@ func (p *ControllerRegistor) ServeHTTP(rw http.ResponseWriter, r *http.Request) ...@@ -575,7 +575,7 @@ func (p *ControllerRegistor) ServeHTTP(rw http.ResponseWriter, r *http.Request)
575 if requestPath == route.pattern { 575 if requestPath == route.pattern {
576 runrouter = route.controllerType 576 runrouter = route.controllerType
577 findrouter = true 577 findrouter = true
578 runMethod = p.getRunMethod(r.Method, context.Input.Query("_method"), route) 578 runMethod = p.getRunMethod(r.Method, context, route)
579 break 579 break
580 } 580 }
581 // pattern /admin url /admin 200 /admin/ 404 581 // pattern /admin url /admin 200 /admin/ 404
...@@ -618,7 +618,7 @@ func (p *ControllerRegistor) ServeHTTP(rw http.ResponseWriter, r *http.Request) ...@@ -618,7 +618,7 @@ func (p *ControllerRegistor) ServeHTTP(rw http.ResponseWriter, r *http.Request)
618 runrouter = route.controllerType 618 runrouter = route.controllerType
619 findrouter = true 619 findrouter = true
620 context.Input.Params = params 620 context.Input.Params = params
621 runMethod = p.getRunMethod(r.Method, context.Input.Query("_method"), route) 621 runMethod = p.getRunMethod(r.Method, context, route)
622 break 622 break
623 } 623 }
624 } 624 }
...@@ -788,7 +788,7 @@ func (p *ControllerRegistor) getErrorHandler(errorCode string) func(rw http.Resp ...@@ -788,7 +788,7 @@ func (p *ControllerRegistor) getErrorHandler(errorCode string) func(rw http.Resp
788 return handler 788 return handler
789 } 789 }
790 790
791 func (p *ControllerRegistor) getRunMethod(method, _method string, router *controllerInfo) string { 791 func (p *ControllerRegistor) getRunMethod(method string, context *beecontext.Context, router *controllerInfo) string {
792 method = strings.ToLower(method) 792 method = strings.ToLower(method)
793 if router.hasMethod { 793 if router.hasMethod {
794 if m, ok := router.methods[method]; ok { 794 if m, ok := router.methods[method]; ok {
...@@ -796,19 +796,19 @@ func (p *ControllerRegistor) getRunMethod(method, _method string, router *contro ...@@ -796,19 +796,19 @@ func (p *ControllerRegistor) getRunMethod(method, _method string, router *contro
796 } else if m, ok = router.methods["*"]; ok { 796 } else if m, ok = router.methods["*"]; ok {
797 return m 797 return m
798 } else { 798 } else {
799 if method == "POST" || strings.ToLower(_method) == "put" { 799 if method == "POST" && strings.ToLower(context.Input.Query("_method")) == "put" {
800 return "Put" 800 return "Put"
801 } 801 }
802 if method == "POST" || strings.ToLower(_method) == "delete" { 802 if method == "POST" && strings.ToLower(context.Input.Query("_method")) == "delete" {
803 return "Delete" 803 return "Delete"
804 } 804 }
805 return strings.Title(method) 805 return strings.Title(method)
806 } 806 }
807 } else { 807 } else {
808 if method == "POST" || strings.ToLower(_method) == "put" { 808 if method == "POST" && strings.ToLower(context.Input.Query("_method")) == "put" {
809 return "Put" 809 return "Put"
810 } 810 }
811 if method == "POST" || strings.ToLower(_method) == "delete" { 811 if method == "POST" && strings.ToLower(context.Input.Query("_method")) == "delete" {
812 return "Delete" 812 return "Delete"
813 } 813 }
814 return strings.Title(method) 814 return strings.Title(method)
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!