1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-12-22 19:07:54 +01:00

Fix pathname reporting in middlewares

This commit is contained in:
ivaosthu 2017-12-18 15:12:44 +01:00 committed by Ivar Conradi Østhus
parent 1695a35555
commit 57df35f6a5
2 changed files with 6 additions and 2 deletions

View File

@ -1,12 +1,14 @@
'use strict';
const url = require('url');
const logger = require('../logger')('HTTP');
module.exports = function(config) {
return (req, res, next) => {
next();
if (config.enableRequestLogger) {
logger.info(`${res.statusCode} ${req.method} ${req.baseUrl}`);
const { pathname } = url.parse(req.originalUrl);
logger.info(`${res.statusCode} ${req.method} ${pathname}`);
}
};
};

View File

@ -1,12 +1,14 @@
'use strict';
const url = require('url');
const responseTime = require('response-time');
const { REQUEST_TIME } = require('../events');
module.exports = function(config) {
return responseTime((req, res, time) => {
const { pathname } = url.parse(req.originalUrl);
const timingInfo = {
path: req.baseUrl,
path: pathname,
method: req.method,
statusCode: res.statusCode,
time,