Extract initProfiler middlewar
This commit is contained in:
parent
d8d681e8bc
commit
64d540f23b
@ -8,6 +8,7 @@ const cleanUpQueryParams = require('../../middleware/clean-up-query-params');
|
|||||||
const credentials = require('../../middleware/credentials');
|
const credentials = require('../../middleware/credentials');
|
||||||
const dbConnSetup = require('../../middleware/db-conn-setup');
|
const dbConnSetup = require('../../middleware/db-conn-setup');
|
||||||
const authorize = require('../../middleware/authorize');
|
const authorize = require('../../middleware/authorize');
|
||||||
|
const initProfiler = require('./middlewares/init-profiler');
|
||||||
const cacheControlHeader = require('../../middleware/cache-control-header');
|
const cacheControlHeader = require('../../middleware/cache-control-header');
|
||||||
const cacheChannelHeader = require('../../middleware/cache-channel-header');
|
const cacheChannelHeader = require('../../middleware/cache-channel-header');
|
||||||
const surrogateKeyHeader = require('../../middleware/surrogate-key-header');
|
const surrogateKeyHeader = require('../../middleware/surrogate-key-header');
|
||||||
@ -109,16 +110,6 @@ AnonymousMapController.prototype.composeCreateMapMiddleware = function () {
|
|||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
function initProfiler (isTemplateInstantiation) {
|
|
||||||
const operation = isTemplateInstantiation ? 'instance_template' : 'createmap';
|
|
||||||
|
|
||||||
return function initProfilerMiddleware (req, res, next) {
|
|
||||||
req.profiler.start(`windshaft-cartodb.${operation}_${req.method.toLowerCase()}`);
|
|
||||||
req.profiler.done(`${operation}.initProfilerMiddleware`);
|
|
||||||
next();
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
function checkJsonContentType () {
|
function checkJsonContentType () {
|
||||||
return function checkJsonContentTypeMiddleware(req, res, next) {
|
return function checkJsonContentTypeMiddleware(req, res, next) {
|
||||||
if (req.method === 'POST' && !req.is('application/json')) {
|
if (req.method === 'POST' && !req.is('application/json')) {
|
||||||
|
9
lib/cartodb/controllers/map/middlewares/init-profiler.js
Normal file
9
lib/cartodb/controllers/map/middlewares/init-profiler.js
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
module.exports = function initProfiler (isTemplateInstantiation) {
|
||||||
|
const operation = isTemplateInstantiation ? 'instance_template' : 'createmap';
|
||||||
|
|
||||||
|
return function initProfilerMiddleware (req, res, next) {
|
||||||
|
req.profiler.start(`windshaft-cartodb.${operation}_${req.method.toLowerCase()}`);
|
||||||
|
req.profiler.done(`${operation}.initProfilerMiddleware`);
|
||||||
|
next();
|
||||||
|
};
|
||||||
|
};
|
@ -4,6 +4,7 @@ const cleanUpQueryParams = require('../../middleware/clean-up-query-params');
|
|||||||
const credentials = require('../../middleware/credentials');
|
const credentials = require('../../middleware/credentials');
|
||||||
const dbConnSetup = require('../../middleware/db-conn-setup');
|
const dbConnSetup = require('../../middleware/db-conn-setup');
|
||||||
const authorize = require('../../middleware/authorize');
|
const authorize = require('../../middleware/authorize');
|
||||||
|
const initProfiler = require('./middlewares/init-profiler');
|
||||||
const cacheControlHeader = require('../../middleware/cache-control-header');
|
const cacheControlHeader = require('../../middleware/cache-control-header');
|
||||||
const cacheChannelHeader = require('../../middleware/cache-channel-header');
|
const cacheChannelHeader = require('../../middleware/cache-channel-header');
|
||||||
const surrogateKeyHeader = require('../../middleware/surrogate-key-header');
|
const surrogateKeyHeader = require('../../middleware/surrogate-key-header');
|
||||||
@ -119,16 +120,6 @@ NamedMapController.prototype.composeInstantiateTemplateMiddleware = function ()
|
|||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
function initProfiler (isTemplateInstantiation) {
|
|
||||||
const operation = isTemplateInstantiation ? 'instance_template' : 'createmap';
|
|
||||||
|
|
||||||
return function initProfilerMiddleware (req, res, next) {
|
|
||||||
req.profiler.start(`windshaft-cartodb.${operation}_${req.method.toLowerCase()}`);
|
|
||||||
req.profiler.done(`${operation}.initProfilerMiddleware`);
|
|
||||||
next();
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
function checkJsonContentType () {
|
function checkJsonContentType () {
|
||||||
return function checkJsonContentTypeMiddleware(req, res, next) {
|
return function checkJsonContentTypeMiddleware(req, res, next) {
|
||||||
if (req.method === 'POST' && !req.is('application/json')) {
|
if (req.method === 'POST' && !req.is('application/json')) {
|
||||||
|
Loading…
Reference in New Issue
Block a user