http-simple-proxy
Version:
Simple http/https proxy daemon. Proxying based on the excellent node-http-master.
19 lines (18 loc) • 452 B
JavaScript
module.exports = function AddHeaderMiddleware() {
return {
requestHandler: function(req, res, next, target) {
if(!req.upgrade) {
req.headers[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;
}
};
};