mirror of
https://github.com/astaxie/beego.git
synced 2024-11-26 05:21:30 +00:00
when method is POST then to parse form
This commit is contained in:
parent
cb49be7815
commit
53b2a29b44
14
router.go
14
router.go
@ -575,7 +575,7 @@ func (p *ControllerRegistor) ServeHTTP(rw http.ResponseWriter, r *http.Request)
|
|||||||
if requestPath == route.pattern {
|
if requestPath == route.pattern {
|
||||||
runrouter = route.controllerType
|
runrouter = route.controllerType
|
||||||
findrouter = true
|
findrouter = true
|
||||||
runMethod = p.getRunMethod(r.Method, context.Input.Query("_method"), route)
|
runMethod = p.getRunMethod(r.Method, context, route)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
// pattern /admin url /admin 200 /admin/ 404
|
// pattern /admin url /admin 200 /admin/ 404
|
||||||
@ -618,7 +618,7 @@ func (p *ControllerRegistor) ServeHTTP(rw http.ResponseWriter, r *http.Request)
|
|||||||
runrouter = route.controllerType
|
runrouter = route.controllerType
|
||||||
findrouter = true
|
findrouter = true
|
||||||
context.Input.Params = params
|
context.Input.Params = params
|
||||||
runMethod = p.getRunMethod(r.Method, context.Input.Query("_method"), route)
|
runMethod = p.getRunMethod(r.Method, context, route)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -788,7 +788,7 @@ func (p *ControllerRegistor) getErrorHandler(errorCode string) func(rw http.Resp
|
|||||||
return handler
|
return handler
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *ControllerRegistor) getRunMethod(method, _method string, router *controllerInfo) string {
|
func (p *ControllerRegistor) getRunMethod(method string, context *beecontext.Context, router *controllerInfo) string {
|
||||||
method = strings.ToLower(method)
|
method = strings.ToLower(method)
|
||||||
if router.hasMethod {
|
if router.hasMethod {
|
||||||
if m, ok := router.methods[method]; ok {
|
if m, ok := router.methods[method]; ok {
|
||||||
@ -796,19 +796,19 @@ func (p *ControllerRegistor) getRunMethod(method, _method string, router *contro
|
|||||||
} else if m, ok = router.methods["*"]; ok {
|
} else if m, ok = router.methods["*"]; ok {
|
||||||
return m
|
return m
|
||||||
} else {
|
} else {
|
||||||
if method == "POST" || strings.ToLower(_method) == "put" {
|
if method == "POST" && strings.ToLower(context.Input.Query("_method")) == "put" {
|
||||||
return "Put"
|
return "Put"
|
||||||
}
|
}
|
||||||
if method == "POST" || strings.ToLower(_method) == "delete" {
|
if method == "POST" && strings.ToLower(context.Input.Query("_method")) == "delete" {
|
||||||
return "Delete"
|
return "Delete"
|
||||||
}
|
}
|
||||||
return strings.Title(method)
|
return strings.Title(method)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if method == "POST" || strings.ToLower(_method) == "put" {
|
if method == "POST" && strings.ToLower(context.Input.Query("_method")) == "put" {
|
||||||
return "Put"
|
return "Put"
|
||||||
}
|
}
|
||||||
if method == "POST" || strings.ToLower(_method) == "delete" {
|
if method == "POST" && strings.ToLower(context.Input.Query("_method")) == "delete" {
|
||||||
return "Delete"
|
return "Delete"
|
||||||
}
|
}
|
||||||
return strings.Title(method)
|
return strings.Title(method)
|
||||||
|
Loading…
Reference in New Issue
Block a user