Implement stats middleware removing some duplicated code

This commit is contained in:
Daniel García Aubert
2017-10-05 17:06:42 +02:00
parent b93c09959c
commit bf637ccd5b
4 changed files with 40 additions and 29 deletions
@@ -35,8 +35,6 @@ module.exports = function errorMiddleware (/* options */) {
res.set('X-Served-By-DB-Host', res.locals.dbhost);
}
res.set('X-Tiler-Profiler', req.profiler.toJSONString());
res.status(statusCode);
if (req.query && req.query.callback) {
@@ -44,14 +42,6 @@ module.exports = function errorMiddleware (/* options */) {
} else {
res.json(errorResponseBody);
}
try {
// May throw due to dns, see
// See http://github.com/CartoDB/Windshaft/issues/166
req.profiler.sendStats();
} catch (err) {
debug("error sending profiling stats: " + err);
}
};
};