UNPKG

http-simple-proxy

Version:

Simple http/https proxy daemon. Proxying based on the excellent node-http-master.

19 lines (18 loc) 453 B
module.exports = function AddHeaderMiddleware() { return { requestHandler: function(req, res, next, target) { if(!req.upgrade) { res.setHeader(target[0], target[1]); } next(); }, entryParser: function(config) { if(!config.match(/\s*=\s*/)) { throw new Error('Bad format, should be key=value'); } var m = config.match(/^(.*?)\s*=\s*(.*$)/); m.shift(); return m; } }; };