Dump all registered routes
bentcoder opened this issue · comments
bentcoder commented
Hi,
Is there a way to dump list of all registered routes and methods?
Thanks
POST /api/v1/users
GET /api/v2/comments/:id
DELETE /api/v2/comments/:id
...
Joe Williams commented
Consider wrapping the router, and then replacing it, but using RLock when serving.
type MyRouter struct {
router *router.Router
lock sync.RWMutex
}
func (r *MyRouter) ReplaceRouter(router *router.Router) {
r.lock.Lock()
defer r.lock.Unlock()
r.router = router
}
func (r *MyRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) {
r.lock.RLock()
defer r.lock.RUnlock()
r.router.ServeHTTP(w, req)
}
Joseph Harnish commented
@bubbajoe I think he was asking for a way to output the list, not drop the routes.
letmestudy commented
这是来自QQ邮箱的假期自动回复邮件。
您好,我最近正在休假中,无法亲自回复您的邮件。我将在假期结束后,尽快给您回复。