This commit is contained in:
Gerasimos (Makis) Maropoulos 2022-11-25 23:53:39 +02:00
parent 6a49bc8315
commit 2bd10b1a25
No known key found for this signature in database
GPG Key ID: B9839E9CD30B7B6B

View File

@ -68,7 +68,13 @@ func (repo *repository) getRelative(r *Route) *Route {
}
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
}
}
@ -124,11 +130,10 @@ func (repo *repository) register(route *Route, rule RouteRegisterRule) (*Route,
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)
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)`
route.RegisterFileName = filename
route.RegisterLineNumber = line
route.RegisterFileName = mainHandlerFileName // filename
route.RegisterLineNumber = mainHandlerFileNumber // line
route.MainHandlerName = mainHandlerName
route.MainHandlerIndex = mainHandlerIndex