Skip to content
This repository has been archived by the owner on Jan 10, 2022. It is now read-only.

Default Routing #122

Open
cliftonc opened this issue Oct 4, 2011 · 0 comments
Open

Default Routing #122

cliftonc opened this issue Oct 4, 2011 · 0 comments

Comments

@cliftonc
Copy link
Owner

cliftonc commented Oct 4, 2011

I was reading through the code for this https://github.com/visionmedia/express-resource 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 subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant