Created
April 16, 2014 15:46
-
-
Save Stwissel/10896955 to your computer and use it in GitHub Desktop.
POC for a filtering proxy, botched attempt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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