Skip to content

Instantly share code, notes, and snippets.

@fnakstad
Created August 4, 2013 14:02
Show Gist options
  • Save fnakstad/6150416 to your computer and use it in GitHub Desktop.
Save fnakstad/6150416 to your computer and use it in GitHub Desktop.
module.exports = function(app) {
_.each(routes, function(route) {
var args = _.flatten([route.path, route.middleware]);
switch(route.httpMethod.toUpperCase()) {
case 'GET':
app.get.apply(app, args);
break;
case 'POST':
app.post.apply(app, args);
break;
case 'PUT':
app.put.apply(app, args);
break;
case 'DELETE':
app.delete.apply(app, args);
break;
default:
throw new Error('Invalid HTTP method specified for route ' + route.path);
break;
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment