Created
July 6, 2012 18:12
-
-
Save regality/3061748 to your computer and use it in GitHub Desktop.
attempt at expressjs domains
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
app.use(function(req, res, next) { | |
var reqd = domain.create(); | |
reqd.add(req); | |
reqd.add(res); | |
reqd.on('error', function(err) { | |
app.log.error(err + ' for url ' + req.url); | |
req.next(err); | |
}); | |
res.on('finish', function() { | |
console.log('disposing'); | |
reqd.dispose(); | |
}); | |
reqd.run(next); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment