ddo / go-mux-mvc

golang gorilla/mux mvc template
MIT License
5 stars 2 forks source link

Subrouter per page #1

Open martinbeentjes opened 7 years ago

martinbeentjes commented 7 years ago

Awesome little bootstrap for a MVC project. I was wondering, wouldn't it be a bit nicer to have subrouters per /{page}/? So each controller gets a prefixed router?

ddo commented 7 years ago

you mean here https://github.com/ddo/go-mux-mvc/blob/master/controllers/controllers.go ?

martinbeentjes commented 7 years ago

Yes. There you define per route the exact method. Shouldn't it be 'prettier' to assign the /products to the ProductController via a prefix? And then define all the routes? Or is this an ugly idea?

ddo commented 7 years ago

yeah most of the other mvc frameworks supports like that i guess. but i think the currently way is more flexible

martinbeentjes commented 7 years ago

One downside: controllers.go now has an understanding of the routes of the other subcontrollers. I see the collection of routes with a prefix /products/ to be part of a products service.

To keep my project clean, I want all innercode to stay inside that service. Which means to keep all the route definitions in that specific controller folder.

ddo commented 7 years ago

good idea i just recently switch to chi since mux is lack of middleware. gonna push some changes to the template later then