Created
March 23, 2013 00:18
-
-
Save caridy/5225738 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 m1 = function (req, res, next) { | |
next(); | |
}; | |
var m2 = function (req, res, next) { | |
next(); | |
} | |
var m3 = function (req, res, next) { | |
next(); | |
// or next(new Error('ops!')); | |
}; | |
module.exports = function(config) { | |
return function (req, res, next) { | |
var all = [m1, m2, m3]; | |
function run () { | |
var m = all.shift(); | |
if (!m) { | |
return next(); | |
} | |
m(req, res, function (err) { | |
if (err) { | |
return next(err); | |
} | |
run(); | |
}); | |
} | |
}; | |
}; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment