UNPKG

toxy

Version:

Hackable HTTP proxy to simulate server failure scenarios and network conditions

14 lines (11 loc) 336 B
module.exports = function contentType (filter) { if (typeof filter === 'string') { filter = new RegExp(filter, 'i') } return function contentType (req, res, next) { const type = req.headers['content-type'] if (!type) return next(null, true) const notMatches = !filter.test(type) next(null, notMatches) } }