Created
July 15, 2019 16:23
-
-
Save liesislukas/809b4e94edae9b46d084568271f417b8 to your computer and use it in GitHub Desktop.
express nodejs after response listener sample
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
app.use(function (req, res, next) { | |
function afterResponse() { | |
res.removeListener('finish', afterResponse); | |
res.removeListener('close', afterResponse); | |
var log = logger.loggerInstance.child({ | |
id: req.id | |
}, true) | |
log.info({res:res}, 'response') | |
} | |
res.on('finish', afterResponse); | |
res.on('close', afterResponse); | |
next(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment