mirror of
https://github.com/astaxie/beego.git
synced 2024-11-22 17:30:56 +00:00
clearly the router, If user set the third params, will not follow the RESTful method
This commit is contained in:
parent
fc19f8f183
commit
0b659961ba
14
router.go
14
router.go
@ -566,11 +566,13 @@ func (p *ControllerRegistor) ServeHTTP(rw http.ResponseWriter, r *http.Request)
|
|||||||
for _, route := range p.fixrouters {
|
for _, route := range p.fixrouters {
|
||||||
n := len(requestPath)
|
n := len(requestPath)
|
||||||
if requestPath == route.pattern {
|
if requestPath == route.pattern {
|
||||||
|
runMethod = p.getRunMethod(r.Method, context, route)
|
||||||
|
if runMethod != "" {
|
||||||
runrouter = route.controllerType
|
runrouter = route.controllerType
|
||||||
findrouter = true
|
findrouter = true
|
||||||
runMethod = p.getRunMethod(r.Method, context, route)
|
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// pattern /admin url /admin 200 /admin/ 404
|
// pattern /admin url /admin 200 /admin/ 404
|
||||||
// pattern /admin/ url /admin 301 /admin/ 200
|
// pattern /admin/ url /admin 301 /admin/ 200
|
||||||
if requestPath[n-1] != '/' && len(route.pattern) == n+1 &&
|
if requestPath[n-1] != '/' && len(route.pattern) == n+1 &&
|
||||||
@ -608,13 +610,15 @@ func (p *ControllerRegistor) ServeHTTP(rw http.ResponseWriter, r *http.Request)
|
|||||||
//reassemble query params and add to RawQuery
|
//reassemble query params and add to RawQuery
|
||||||
r.URL.RawQuery = url.Values(values).Encode()
|
r.URL.RawQuery = url.Values(values).Encode()
|
||||||
}
|
}
|
||||||
runrouter = route.controllerType
|
|
||||||
findrouter = true
|
|
||||||
context.Input.Params = params
|
|
||||||
runMethod = p.getRunMethod(r.Method, context, route)
|
runMethod = p.getRunMethod(r.Method, context, route)
|
||||||
|
if runMethod != "" {
|
||||||
|
runrouter = route.controllerType
|
||||||
|
context.Input.Params = params
|
||||||
|
findrouter = true
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if !findrouter && p.enableAuto {
|
if !findrouter && p.enableAuto {
|
||||||
// deal with url with diffirent ext
|
// deal with url with diffirent ext
|
||||||
@ -798,7 +802,7 @@ func (p *ControllerRegistor) getRunMethod(method string, context *beecontext.Con
|
|||||||
} else if m, ok = router.methods["*"]; ok {
|
} else if m, ok = router.methods["*"]; ok {
|
||||||
return m
|
return m
|
||||||
} else {
|
} else {
|
||||||
return strings.Title(method)
|
return ""
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return strings.Title(method)
|
return strings.Title(method)
|
||||||
|
Loading…
Reference in New Issue
Block a user