fix the same name controller for UrlFor
Showing
1 changed file
with
3 additions
and
2 deletions
| ... | @@ -415,7 +415,7 @@ func (p *ControllerRegistor) UrlFor(endpoint string, values ...string) string { | ... | @@ -415,7 +415,7 @@ func (p *ControllerRegistor) UrlFor(endpoint string, values ...string) string { |
| 415 | } | 415 | } |
| 416 | } | 416 | } |
| 417 | } | 417 | } |
| 418 | controllName := strings.Join(paths[:len(paths)-1], ".") | 418 | controllName := strings.Join(paths[:len(paths)-1], "/") |
| 419 | methodName := paths[len(paths)-1] | 419 | methodName := paths[len(paths)-1] |
| 420 | for _, t := range p.routers { | 420 | for _, t := range p.routers { |
| 421 | ok, url := p.geturl(t, "/", controllName, methodName, params) | 421 | ok, url := p.geturl(t, "/", controllName, methodName, params) |
| ... | @@ -443,7 +443,8 @@ func (p *ControllerRegistor) geturl(t *Tree, url, controllName, methodName strin | ... | @@ -443,7 +443,8 @@ func (p *ControllerRegistor) geturl(t *Tree, url, controllName, methodName strin |
| 443 | } | 443 | } |
| 444 | for _, l := range t.leaves { | 444 | for _, l := range t.leaves { |
| 445 | if c, ok := l.runObject.(*controllerInfo); ok { | 445 | if c, ok := l.runObject.(*controllerInfo); ok { |
| 446 | if c.routerType == routerTypeBeego && c.controllerType.Name() == controllName { | 446 | if c.routerType == routerTypeBeego && |
| 447 | strings.HasSuffix(path.Join(c.controllerType.PkgPath(), c.controllerType.Name()), controllName) { | ||
| 447 | find := false | 448 | find := false |
| 448 | if _, ok := HTTPMETHOD[strings.ToUpper(methodName)]; ok { | 449 | if _, ok := HTTPMETHOD[strings.ToUpper(methodName)]; ok { |
| 449 | if len(c.methods) == 0 { | 450 | if len(c.methods) == 0 { | ... | ... |
-
Please register or sign in to post a comment