You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a project with a large number of routes. Many of them have URL params. Some of them are grouped into subrouters.
When I have an issue at a particular URL, sometimes it is difficult to determine what handler is responsible.
For example, given the README.md example routes:
r.Route("/articles", func(r chi.Router) {
r.With(paginate).Get("/", listArticles) // GET /articlesr.With(paginate).Get("/{month}-{day}-{year}", listArticlesByDate) // GET /articles/01-16-2017r.Post("/", createArticle) // POST /articlesr.Get("/search", searchArticles) // GET /articles/search// Regexp url parameters:r.Get("/{articleSlug:[a-z-]+}", getArticleBySlug) // GET /articles/home-is-toronto// Subrouters:r.Route("/{articleID}", func(r chi.Router) {
r.Use(ArticleCtx)
r.Get("/", getArticle) // GET /articles/123r.Put("/", updateArticle) // PUT /articles/123r.Delete("/", deleteArticle) // DELETE /articles/123
})
})
How would I easily find that PUT /articles/123 was routed to the updateArticle function? Obviously, I can go path segment by path segment and eventually find it. But when there are longer paths that can take a little while.
I'm somewhat spoiled by the Ruby on Rails logs where it logs the exact method that handled each request.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I have a project with a large number of routes. Many of them have URL params. Some of them are grouped into subrouters.
When I have an issue at a particular URL, sometimes it is difficult to determine what handler is responsible.
For example, given the README.md example routes:
How would I easily find that
PUT /articles/123
was routed to theupdateArticle
function? Obviously, I can go path segment by path segment and eventually find it. But when there are longer paths that can take a little while.I'm somewhat spoiled by the Ruby on Rails logs where it logs the exact method that handled each request.
Beta Was this translation helpful? Give feedback.
All reactions