mirror of
				https://github.com/Unleash/unleash.git
				synced 2025-10-27 11:02:16 +01:00 
			
		
		
		
	Fix pathname reporting in middlewares
This commit is contained in:
		
							parent
							
								
									f9b4455519
								
							
						
					
					
						commit
						4f74c90376
					
				@ -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}`);
 | 
			
		||||
        }
 | 
			
		||||
    };
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
@ -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,
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user