mirror of
https://github.com/gin-gonic/gin.git
synced 2025-10-24 02:32:17 +08:00
List the handlers during start-up
This commit is contained in:
parent
4afad25189
commit
1816795d62
10
debug.go
10
debug.go
@ -33,16 +33,16 @@ func debugPrintRoute(httpMethod, absolutePath string, handlers HandlersChain) {
|
||||
|
||||
if terminal.IsTerminal(int(os.Stdout.Fd())) {
|
||||
w, _, _ = terminal.GetSize(int(os.Stdout.Fd()))
|
||||
w -= 25
|
||||
} else {
|
||||
fmt.Println("Couldn't get terminal size. Using default value...")
|
||||
debugPrint("Couldn't get terminal size. Using default value...\n")
|
||||
}
|
||||
fmt.Printf(fmt.Sprintf("%%%ds\n", w/2), s)
|
||||
// fmt.Printf(fmt.Sprintf("%%-%ds", w/2), fmt.Sprintf(fmt.Sprintf("%%%ds\n", w/2), s))
|
||||
debugPrint(fmt.Sprintf("%%%ds\n", w/2), s)
|
||||
for i := 0; i < len(handlers); i += 2 {
|
||||
fmt.Printf(" | %-50s | %-50s |\n", runtime.FuncForPC(reflect.ValueOf(handlers[i]).Pointer()).Name(), runtime.FuncForPC(reflect.ValueOf(handlers[i+1]).Pointer()).Name())
|
||||
debugPrint("| %-50s | %-50s |\n", runtime.FuncForPC(reflect.ValueOf(handlers[i]).Pointer()).Name(), runtime.FuncForPC(reflect.ValueOf(handlers[i+1]).Pointer()).Name())
|
||||
}
|
||||
nuHandlers := len(handlers)
|
||||
fmt.Printf("Total %d handlers found...\n", nuHandlers)
|
||||
debugPrint("Total %d handlers found...\n\n", nuHandlers)
|
||||
handlerName := nameOfFunction(handlers.Last())
|
||||
debugPrint("%-6s %-25s --> %s (%d handlers)\n", httpMethod, absolutePath, handlerName, nuHandlers)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user