Created
September 15, 2012 17:31
-
-
Save srounce/3728963 to your computer and use it in GitHub Desktop.
Simple route specific middleware
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
var routeSpecificMiddleware = { | |
'/' : [], | |
'/private' : [ myAuthMiddleware ], | |
'/edit' : [ myAuthMiddleware, validator ], | |
'/register' : [ validator ] | |
}; | |
var bindRoute = function(app, route, verb, handler) | |
{ | |
verb = verb || 'all'; | |
app[verb](route, routeSpecificMiddleware[route], handler); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment