feat: print routes (#1964)

* feat: print rest routes

* feat: print rest routes
This commit is contained in:
Kevin Wan
2022-06-04 13:26:14 +08:00
committed by GitHub
parent 87800419f5
commit b6b96d9dad
3 changed files with 88 additions and 0 deletions

View File

@@ -5,6 +5,7 @@ import (
"errors"
"fmt"
"net/http"
"sort"
"time"
"github.com/justinas/alice"
@@ -184,6 +185,22 @@ func (ng *engine) notFoundHandler(next http.Handler) http.Handler {
})
}
func (ng *engine) print() {
var routes []string
for _, fr := range ng.routes {
for _, route := range fr.routes {
routes = append(routes, fmt.Sprintf("%s %s", route.Method, route.Path))
}
}
sort.Strings(routes)
for _, route := range routes {
fmt.Println(route)
}
}
func (ng *engine) setTlsConfig(cfg *tls.Config) {
ng.tlsConfig = cfg
}