Locomotive's router supports verb routing in the form of this.VERB()
, where
VERB is one of the HTTP methods, such as this.post()
.
this.post('bands', 'bands#create');
Verb routing is syntactic sugar for match routes, meaning the above route is equivalent to:
this.match('bands', 'bands#create', { via: 'post' });
Middleware and route handling functions can also be passed as arguments to verb routes:
this.get('/user/:id', user.load, function(req, res) {
res.json(req.locals.user);
});
When use in this form, Locomotive's router supports the API exposed by Express for routing, making it easy to gradually refactor routes from Express to an MVC architecture when needed.