Closed rosshadden closed 10 years ago
edit: {
get: [
function(req, res, next) {
res.view();
},
function(req, res, next) {
res.view();
},
],
post: function(req, res, next) {
app.db.save(req.body)
.then(res.json);
}
},
"edit/:id": {
get: [
function(req, res, next, id) {
res.view();
},
function(req, res, next, id) {
res.view();
},
]
}
Putting this here so we don't lose track. There are a couple simple syntax rules that when used together can allow for a huge amount of flexibility. Note that when I say "route" I mean the keys of the controller object, and by "action" I mean the values of those keys.
"test"
would get the URL/controller/test
."a/:b/:c?"
is valid, and would get the following URLs:/controller/a/test
/controller/a/hello/world
"*"
is shorthand for "everything from this point"."*"
as a controller route gets the following URLs:/controller/aoeu
/controller/asdf/qwer/zxcv
"/"
are not treated as relative to the controller they are in, but instead to the root of the application. This allows for weird URL structures that don't adhere to MVC's typical/:controller/:action/:id?
mantra. A route of"/test"
in a controller would get the URL/test
.Using these building blocks, these are all things that will be supported for controller actions: