-
Notifications
You must be signed in to change notification settings - Fork 62
/
simple.js
40 lines (29 loc) · 830 Bytes
/
simple.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
var http = require('http'),
connect = require('connect'),
httpProxy = require('http-proxy');
var selects = [];
var simpleselect = {};
simpleselect.query = '.b';
simpleselect.func = function (node) {
node.createWriteStream().end('<div>+ Trumpet</div>');
}
selects.push(simpleselect);
//
// Basic Connect App
//
var app = connect();
var proxy = httpProxy.createProxyServer({
target: 'http://localhost:9000'
})
app.use(require('../')([], selects));
app.use(
function (req, res) {
proxy.web(req, res);
}
);
http.createServer(app).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);