You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

19 lines
720 B

const _ = require('lodash');
const Debug = require('../../helper/debug');
const debugLog = new Debug('controller:predicates:is_layer_requested');
const stackTraceLine = require('../../helper/stackTraceLine');
// this function returns true IFF request.clean.layers is either undefined or
// contains the supplied layer
module.exports = layer => {
return (request, response) => {
// default request.clean.layers to the requested layer for simpler "contains" logic
const is_layer_requested = _.get(request, ['clean', 'layers'], [layer]).indexOf(layer) >= 0;
debugLog.push(request, () => ({
reply: is_layer_requested,
stack_trace: stackTraceLine()
}));
return is_layer_requested;
};
};