Created
September 9, 2011 01:21
-
-
Save alexbosworth/1205256 to your computer and use it in GitHub Desktop.
Micro Express.js
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
exports.respond = function(req, res) { | |
var responders = []; | |
for (var i = 2, arg; arg = arguments[i]; i++) responders.push(arguments[i]); | |
var next = function() { | |
var responder = responders.shift(); | |
if (typeof(responder) != 'function') return; | |
var withArgs = responder.apply(null, [req, res, next]); | |
if (typeof(withArgs) == 'function') return withArgs(); | |
}; | |
next(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment