I am learning Golang and decided to try out Iris as it is currently the most popular framework, just out of curiosity.
How do I group routes into external files?
main.go
// See apiRoutes here
apiRouter := iris.Party("/api", apiRoutes)
api_routes.go
func apiRoutes() {
iris.Get("/blog", ...)
iris.Get("/news", ...)
}
So a call to /api/blog
would be processed within api_routes.go
inside the iris.Get("/blog")
function.
Update: My current project structure is like so. I would also like to continuously nest my routes:
|- Routes
|- api_routes.go
|- blog
|- blog_routes.go
|- posts
blog_posts_routes.go
|- categories
blog_categories_routes.go
|- main.go