Default Routing #122

cliftonc opened this Issue Oct 4, 2011 · 0 comments


None yet
1 participant

cliftonc commented Oct 4, 2011

I was reading through the code for this and realised it would be useful to have a function that lets you define a set of default routes for a module.

e.g. from the site above we could do the following for an API module

module.route.defaultResource() >>

GET /forums -> index
GET /forums/new -> new
POST /forums -> create
GET /forums/:forum -> show
GET /forums/:forum/edit -> edit
PUT /forums/:forum -> update
DELETE /forums/:forum -> destroy

Where each of the functions on the right would need to be defined (and exported - which is a change) by the module.

We could also add a non-restful version to degrade to default:

module.route.default() >> fn / template / block

GET /forums -> index / index.html / content.forums.index etc.
GET /forums/new -> new
POST /forums -> create
GET /forums/:forum -> show
GET /forums/:forum/edit -> edit
POST /forums/:forum -> update
GET /forums/:forum/delete -> destroy

You could then add additional, complex routes on top.

module.route.defaultAdmin() >>

GET /admin/module/forums -> admin / admin.html / admin.modules.forums etc.
POST /admin/module/forums -> adminUpdate

... ? You would need to pass things in (e.g. like a map of permissions to routes).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment