package routes import ( "os" "reflect" "runtime" "strings" "github.com/olekukonko/tablewriter" "zestack.dev/slim" ) func printRoutes(router slim.Router) { table := tablewriter.NewWriter(os.Stdout) table.SetHeader([]string{"Method", "Pattern", "Name", "Handler"}) table.SetHeaderAlignment(3) for _, route := range router.Routes() { table.Append([]string{ strings.Join(route.Methods(), ","), route.Pattern(), route.Name(), nameOfFunction(route.Handler()), }) } table.Render() } func nameOfFunction(f any) string { return runtime.FuncForPC(reflect.ValueOf(f).Pointer()).Name() }