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
func routes() gets large and messy soon. I'm wondering how can I split it into several files, ech representing a particular entity?
What I want is something like:
func routes() *httprouter.Router {
r := httprouter.New()
r.NotFound = alice.
New().
ThenFunc(controller.Error404)
notesRoutes()
articlesRoutes()
userRoutes()
return r
}
The text was updated successfully, but these errors were encountered:
bcodus
changed the title
How to split route into
How to split route into several files?
Nov 6, 2021
I'd suggest after you create an instance of r := httprouter.New(), you then store it into a struct and create methods off that in different files or you could just return the return and then call functions in other files, but you will have to pass in *http.Router. Either way works.
func routes()
gets large and messy soon. I'm wondering how can I split it into several files, ech representing a particular entity?What I want is something like:
The text was updated successfully, but these errors were encountered: