Skip to content

Commit

Permalink
Merge 228bc75 into 43a1f53
Browse files Browse the repository at this point in the history
  • Loading branch information
bajtos committed Oct 15, 2018
2 parents 43a1f53 + 228bc75 commit 93b309e
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions server/middleware/rest.js
Expand Up @@ -73,8 +73,21 @@ function rest() {
if (handlers.length === 1) {
return handlers[0](req, res, next);
}
async.eachSeries(handlers, function(handler, done) {
handler(req, res, done);
}, next);

executeHandlers(handlers, req, res, next);
};
}

// A trimmed-down version of async.series that preserves current CLS context
function executeHandlers(handlers, req, res, cb) {
var ix = -1;
next();

function next(err) {
if (err || ++ix >= handlers.length) {
cb(err);
} else {
handlers[ix](req, res, next);
}
}
}

0 comments on commit 93b309e

Please sign in to comment.