mirror of
https://github.com/astaxie/beego.git
synced 2024-11-22 14:10:54 +00:00
_method also must support user defined router
This commit is contained in:
parent
53b2a29b44
commit
e481671814
18
router.go
18
router.go
@ -790,27 +790,21 @@ func (p *ControllerRegistor) getErrorHandler(errorCode string) func(rw http.Resp
|
||||
|
||||
func (p *ControllerRegistor) getRunMethod(method string, context *beecontext.Context, router *controllerInfo) string {
|
||||
method = strings.ToLower(method)
|
||||
if method == "post" && strings.ToLower(context.Input.Query("_method")) == "put" {
|
||||
method = "put"
|
||||
}
|
||||
if method == "post" && strings.ToLower(context.Input.Query("_method")) == "delete" {
|
||||
method = "delete"
|
||||
}
|
||||
if router.hasMethod {
|
||||
if m, ok := router.methods[method]; ok {
|
||||
return m
|
||||
} else if m, ok = router.methods["*"]; ok {
|
||||
return m
|
||||
} else {
|
||||
if method == "POST" && strings.ToLower(context.Input.Query("_method")) == "put" {
|
||||
return "Put"
|
||||
}
|
||||
if method == "POST" && strings.ToLower(context.Input.Query("_method")) == "delete" {
|
||||
return "Delete"
|
||||
}
|
||||
return strings.Title(method)
|
||||
}
|
||||
} else {
|
||||
if method == "POST" && strings.ToLower(context.Input.Query("_method")) == "put" {
|
||||
return "Put"
|
||||
}
|
||||
if method == "POST" && strings.ToLower(context.Input.Query("_method")) == "delete" {
|
||||
return "Delete"
|
||||
}
|
||||
return strings.Title(method)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user