1
0
mirror of https://github.com/kataras/iris.git synced 2025-12-17 18:07:01 +00:00

improve route debug info, see HISTORY.md

Former-commit-id: ae245bae5fefa57c5f7663f7d1d661ec68ad366a
This commit is contained in:
Gerasimos (Makis) Maropoulos
2020-04-26 06:21:20 +03:00
parent 5d3c96947c
commit 77a79cae58
8 changed files with 115 additions and 39 deletions

View File

@@ -444,7 +444,9 @@ func (api *APIBuilder) CreateRoutes(methods []string, relativePath string, handl
mainHandlers := context.Handlers(handlers)
// before join the middleware + handlers + done handlers and apply the execution rules.
possibleMainHandlerName := context.MainHandlerName(mainHandlers)
possibleMainHandlerName, mainHandlerIndex := context.MainHandlerName(mainHandlers)
wd, _ := os.Getwd()
mainHandlerFileName, mainHandlerFileNumber := context.HandlerFileLineRel(handlers[mainHandlerIndex], wd)
// TODO: for UseGlobal/DoneGlobal that doesn't work.
applyExecutionRules(api.handlerExecutionRules, &beginHandlers, &doneHandlers, &mainHandlers)
@@ -470,8 +472,11 @@ func (api *APIBuilder) CreateRoutes(methods []string, relativePath string, handl
continue
}
route.SourceFileName = filename
route.SourceLineNumber = line
route.SourceFileName = mainHandlerFileName
route.SourceLineNumber = mainHandlerFileNumber
route.RegisterFileName = filename
route.RegisterLineNumber = line
// Add UseGlobal & DoneGlobal Handlers
route.Use(api.beginGlobalHandlers...)
@@ -1011,8 +1016,8 @@ func getCaller() (string, int) {
}
if !strings.Contains(file, "/kataras/iris") ||
strings.Contains(file, "/kataras/iris/_examples") ||
strings.Contains(file, "iris-contrib/examples") {
strings.Contains(file, "_examples") ||
strings.Contains(file, "examples") {
if relFile, err := filepath.Rel(wd, file); err == nil {
file = "./" + relFile
}