mirror of
https://github.com/kataras/iris.git
synced 2025-02-02 15:30:36 +01:00
fix #2008
This commit is contained in:
parent
6a49bc8315
commit
2bd10b1a25
|
@ -68,7 +68,13 @@ func (repo *repository) getRelative(r *Route) *Route {
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, route := range repo.routes {
|
for _, route := range repo.routes {
|
||||||
if r.Subdomain == route.Subdomain && r.StatusCode == route.StatusCode && r.Method == route.Method && r.FormattedPath == route.FormattedPath && !route.tmpl.IsTrailing() {
|
if r.tmpl.Src == route.tmpl.Src { // No topLink on the same route syntax.
|
||||||
|
// Fixes #2008, because of APIBuilder.handle, repo.getRelative and repo.register replacement but with a toplink of the old route.
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
if r.Subdomain == route.Subdomain && r.StatusCode == route.StatusCode && r.Method == route.Method &&
|
||||||
|
r.FormattedPath == route.FormattedPath && !route.tmpl.IsTrailing() {
|
||||||
return route
|
return route
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -124,11 +130,10 @@ func (repo *repository) register(route *Route, rule RouteRegisterRule) (*Route,
|
||||||
repo.routes = append(repo.routes[:i], repo.routes[i+1:]...)
|
repo.routes = append(repo.routes[:i], repo.routes[i+1:]...)
|
||||||
}
|
}
|
||||||
|
|
||||||
continue
|
break // continue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// fmt.Printf("repo.routes append:\t%#+v\n\n", route)
|
|
||||||
repo.routes = append(repo.routes, route)
|
repo.routes = append(repo.routes, route)
|
||||||
|
|
||||||
if route.StatusCode == 0 { // a common resource route, not a status code error handler.
|
if route.StatusCode == 0 { // a common resource route, not a status code error handler.
|
||||||
|
@ -779,8 +784,8 @@ func (api *APIBuilder) createRoutes(errorCode int, methods []string, relativePat
|
||||||
}
|
}
|
||||||
|
|
||||||
// The caller tiself, if anonymous, it's the first line of `app.X("/path", here)`
|
// The caller tiself, if anonymous, it's the first line of `app.X("/path", here)`
|
||||||
route.RegisterFileName = filename
|
route.RegisterFileName = mainHandlerFileName // filename
|
||||||
route.RegisterLineNumber = line
|
route.RegisterLineNumber = mainHandlerFileNumber // line
|
||||||
|
|
||||||
route.MainHandlerName = mainHandlerName
|
route.MainHandlerName = mainHandlerName
|
||||||
route.MainHandlerIndex = mainHandlerIndex
|
route.MainHandlerIndex = mainHandlerIndex
|
||||||
|
|
Loading…
Reference in New Issue
Block a user