Created
August 4, 2013 14:02
-
-
Save fnakstad/6150416 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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