mirror of
https://github.com/astaxie/beego.git
synced 2024-11-22 17:21:02 +00:00
fix #759
This commit is contained in:
parent
9d4ec508bb
commit
c4d8e4a244
16
router.go
16
router.go
@ -452,8 +452,8 @@ func (p *ControllerRegistor) UrlFor(endpoint string, values ...string) string {
|
|||||||
}
|
}
|
||||||
controllName := strings.Join(paths[:len(paths)-1], "/")
|
controllName := strings.Join(paths[:len(paths)-1], "/")
|
||||||
methodName := paths[len(paths)-1]
|
methodName := paths[len(paths)-1]
|
||||||
for _, t := range p.routers {
|
for m, t := range p.routers {
|
||||||
ok, url := p.geturl(t, "/", controllName, methodName, params)
|
ok, url := p.geturl(t, "/", controllName, methodName, params, m)
|
||||||
if ok {
|
if ok {
|
||||||
return url
|
return url
|
||||||
}
|
}
|
||||||
@ -461,17 +461,17 @@ func (p *ControllerRegistor) UrlFor(endpoint string, values ...string) string {
|
|||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *ControllerRegistor) geturl(t *Tree, url, controllName, methodName string, params map[string]string) (bool, string) {
|
func (p *ControllerRegistor) geturl(t *Tree, url, controllName, methodName string, params map[string]string, httpMethod string) (bool, string) {
|
||||||
for k, subtree := range t.fixrouters {
|
for k, subtree := range t.fixrouters {
|
||||||
u := path.Join(url, k)
|
u := path.Join(url, k)
|
||||||
ok, u := p.geturl(subtree, u, controllName, methodName, params)
|
ok, u := p.geturl(subtree, u, controllName, methodName, params, httpMethod)
|
||||||
if ok {
|
if ok {
|
||||||
return ok, u
|
return ok, u
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if t.wildcard != nil {
|
if t.wildcard != nil {
|
||||||
url = path.Join(url, url_placeholder)
|
u := path.Join(url, url_placeholder)
|
||||||
ok, u := p.geturl(t.wildcard, url, controllName, methodName, params)
|
ok, u := p.geturl(t.wildcard, u, controllName, methodName, params, httpMethod)
|
||||||
if ok {
|
if ok {
|
||||||
return ok, u
|
return ok, u
|
||||||
}
|
}
|
||||||
@ -491,8 +491,8 @@ func (p *ControllerRegistor) geturl(t *Tree, url, controllName, methodName strin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !find {
|
if !find {
|
||||||
for _, md := range c.methods {
|
for m, md := range c.methods {
|
||||||
if md == methodName {
|
if (m == "*" || m == httpMethod) && md == methodName {
|
||||||
find = true
|
find = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user