mirror of
https://github.com/astaxie/beego.git
synced 2024-11-22 08:40:54 +00:00
fix router bug: when the request is PUT or DELETE, router can't find the actual route and will throw 404 page to user
This commit is contained in:
parent
f9e991b538
commit
fa1281002e
16
router.go
16
router.go
@ -648,7 +648,21 @@ func (p *ControllerRegistor) ServeHTTP(rw http.ResponseWriter, r *http.Request)
|
||||
}
|
||||
|
||||
if !findrouter {
|
||||
if t, ok := p.routers[r.Method]; ok {
|
||||
http_method := ""
|
||||
|
||||
if r.Method == "POST" && context.Input.Query("_method") == "PUT" {
|
||||
http_method = "PUT"
|
||||
}
|
||||
|
||||
if r.Method == "POST" && context.Input.Query("_method") == "DELETE" {
|
||||
http_method = "DELETE"
|
||||
}
|
||||
|
||||
if http_method != "PUT" && http_method != "DELETE" {
|
||||
http_method = r.Method
|
||||
}
|
||||
|
||||
if t, ok := p.routers[http_method]; ok {
|
||||
runObject, p := t.Match(urlPath)
|
||||
if r, ok := runObject.(*controllerInfo); ok {
|
||||
routerInfo = r
|
||||
|
Loading…
Reference in New Issue
Block a user