Skip to content

Instantly share code, notes, and snippets.

@Stwissel
Created April 16, 2014 15:46
Show Gist options
  • Select an option

  • Save Stwissel/10896955 to your computer and use it in GitHub Desktop.

Select an option

Save Stwissel/10896955 to your computer and use it in GitHub Desktop.

Revisions

  1. Stwissel created this gist Apr 16, 2014.
    29 changes: 29 additions & 0 deletions firsttest.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,29 @@
    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");