Skip to content

Instantly share code, notes, and snippets.

@alexbosworth
Created September 9, 2011 01:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexbosworth/1205256 to your computer and use it in GitHub Desktop.
Save alexbosworth/1205256 to your computer and use it in GitHub Desktop.
Micro Express.js
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