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:
parent
1695a35555
commit
57df35f6a5
@ -1,12 +1,14 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
const url = require('url');
|
||||||
const logger = require('../logger')('HTTP');
|
const logger = require('../logger')('HTTP');
|
||||||
|
|
||||||
module.exports = function(config) {
|
module.exports = function(config) {
|
||||||
return (req, res, next) => {
|
return (req, res, next) => {
|
||||||
next();
|
next();
|
||||||
if (config.enableRequestLogger) {
|
if (config.enableRequestLogger) {
|
||||||
logger.info(`${res.statusCode} ${req.method} ${req.baseUrl}`);
|
const { pathname } = url.parse(req.originalUrl);
|
||||||
|
logger.info(`${res.statusCode} ${req.method} ${pathname}`);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -1,12 +1,14 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
const url = require('url');
|
||||||
const responseTime = require('response-time');
|
const responseTime = require('response-time');
|
||||||
const { REQUEST_TIME } = require('../events');
|
const { REQUEST_TIME } = require('../events');
|
||||||
|
|
||||||
module.exports = function(config) {
|
module.exports = function(config) {
|
||||||
return responseTime((req, res, time) => {
|
return responseTime((req, res, time) => {
|
||||||
|
const { pathname } = url.parse(req.originalUrl);
|
||||||
const timingInfo = {
|
const timingInfo = {
|
||||||
path: req.baseUrl,
|
path: pathname,
|
||||||
method: req.method,
|
method: req.method,
|
||||||
statusCode: res.statusCode,
|
statusCode: res.statusCode,
|
||||||
time,
|
time,
|
||||||
|
Loading…
Reference in New Issue
Block a user