diff --git a/crm/routes.go b/crm/routes.go index e9d473a64..ee4e08a7c 100644 --- a/crm/routes.go +++ b/crm/routes.go @@ -34,7 +34,6 @@ func MountRoutes(r chi.Router) { }) r.Route("/types", func(r chi.Router) { r.Get("/list", types.List) - r.Post("/list", types.List) r.Get("/type/{id}", types.Type) }) diff --git a/crm/templates/http_routes.tpl b/crm/templates/http_routes.tpl index e39d9ddfd..7690d5e88 100644 --- a/crm/templates/http_routes.tpl +++ b/crm/templates/http_routes.tpl @@ -3,6 +3,9 @@ package {package} {load warning.tpl} import ( + "fmt" + "runtime" + "reflect" "github.com/go-chi/chi" ) @@ -17,4 +20,20 @@ func MountRoutes(r chi.Router) { {/foreach} }) {/foreach} + + var printRoutes func(chi.Routes, string, string) + printRoutes = func(r chi.Routes, indent string, prefix string) { + routes := r.Routes() + for _, route := range routes { + if route.SubRoutes != nil && len(route.SubRoutes.Routes()) > 0 { + fmt.Printf(indent+"%s - with %d handlers, %d subroutes\n", route.Pattern, len(route.Handlers), len(route.SubRoutes.Routes())) + printRoutes(route.SubRoutes, indent+"\t", prefix+route.Pattern[:len(route.Pattern)-2]) + } else { + for key, fn := range route.Handlers { + fmt.Printf("%s%s\t%s -> %s\n", indent, key, prefix+route.Pattern, runtime.FuncForPC(reflect.ValueOf(fn).Pointer()).Name()) + } + } + } + } + printRoutes(r, "", "") } \ No newline at end of file