Skip to content

Instantly share code, notes, and snippets.

@Stwissel
Created April 16, 2014 15:46
Show Gist options
  • Save Stwissel/10896955 to your computer and use it in GitHub Desktop.
Save Stwissel/10896955 to your computer and use it in GitHub Desktop.
POC for a filtering proxy, botched attempt
var httpProxy = require('http-proxy');
// Create an array of selects that harmon will process.
var actions = [];
var actionOne = {};
actionOne.query ='body';
actionOne.func = function (node) {
var out = '<h1>You have been proxied</h1>';
node.createWriteStream({ outer: true }).end(out);
console.log("body function called: " + out);
};
var actionTwo = {};
actionTwo.query = 'head';
actionTwo.func = function (node) {
var out = '<style type="text/css"> h1 {color : red; border-bottom : 5px solid green} </style>';
node.createWriteStream({ outer: true }).end(out);
console.log("head function called: " + out);
};
actions.push(actionOne);
actions.push(actionTwo);
var proxy = httpProxy.createServer(
require('../')([], actions),
80, 'www.notessensei.com'
);
proxy.listen(8899);
console.log("Up and running on port 8899 for NotesSensei");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment