Created
May 28, 2012 21:11
-
-
Save No9/2821229 to your computer and use it in GitHub Desktop.
A sample implementation of trumpet in nodejistsu http-proxy
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 http = require('http'), | |
httpProxy = require('http-proxy'), | |
trumpet = require('trumpet'); | |
httpProxy.createServer( | |
function (req, res, next) { | |
var _write = res.write; | |
res.write = function (data) { | |
var tr = trumpet(); | |
tr.select('.b', function (node) { | |
node.replace(function (html) { | |
return '<div>& Trumpet</div>'; | |
}); | |
}); | |
tr.on('data', function (buf) { | |
_write.call(res, buf); | |
}); | |
tr.write(data); | |
} | |
next(); | |
}, | |
9000, 'localhost' | |
).listen(8000); | |
http.createServer(function (req, res) { | |
res.writeHead(200, { 'Content-Type': 'text/html' }); | |
res.write('<html><head></head><body><div class="a">Nodejitsu Http Proxy</div><div class="b">& Frames</div></body></html>'); | |
res.end(); | |
}).listen(9000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@dominictarr "you can also run tap tests just with
node test/test.js
" interesting - I didn't try that.Given the fact you had a similar outcome I think I will stick where I am for now.
TTFN