[examples] Updated examples to v0.7.x API.

This commit is contained in:
Charlie McConnell 2011-09-21 14:11:41 -07:00
parent 24ef919495
commit 8fc8d966c4
2 changed files with 14 additions and 17 deletions

View File

@ -67,12 +67,14 @@ socket.on('connection', function (client) {
// //
// Setup our server to proxy standard HTTP requests // Setup our server to proxy standard HTTP requests
// //
var proxy = new httpProxy.HttpProxy(); var proxy = new httpProxy.HttpProxy({
var proxyServer = http.createServer(function (req, res) { target: {
proxy.proxyRequest(req, res, {
host: 'localhost', host: 'localhost',
port: 8080 port: 8080
}) }
});
var proxyServer = http.createServer(function (req, res) {
proxy.proxyRequest(req, res);
}); });
// //
@ -83,11 +85,7 @@ proxyServer.on('upgrade', function (req, socket, head) {
var buffer = httpProxy.buffer(socket); var buffer = httpProxy.buffer(socket);
setTimeout(function () { setTimeout(function () {
proxy.proxyWebSocketRequest(req, socket, head, { proxy.proxyWebSocketRequest(req, socket, head, buffer);
port: 8080,
host: 'localhost',
buffer: buffer
});
}, 1000); }, 1000);
}); });

View File

@ -67,12 +67,14 @@ socket.on('connection', function (client) {
// //
// Setup our server to proxy standard HTTP requests // Setup our server to proxy standard HTTP requests
// //
var proxy = new httpProxy.HttpProxy(); var proxy = new httpProxy.HttpProxy({
var proxyServer = http.createServer(function (req, res) { target: {
proxy.proxyRequest(req, res, {
host: 'localhost', host: 'localhost',
port: 8080 port: 8080
}) }
});
var proxyServer = http.createServer(function (req, res) {
proxy.proxyRequest(req, res);
}); });
// //
@ -80,10 +82,7 @@ var proxyServer = http.createServer(function (req, res) {
// WebSocket requests as well. // WebSocket requests as well.
// //
proxyServer.on('upgrade', function (req, socket, head) { proxyServer.on('upgrade', function (req, socket, head) {
proxy.proxyWebSocketRequest(req, socket, head, { proxy.proxyWebSocketRequest(req, socket, head);
port: 8080,
host: 'localhost'
});
}); });
proxyServer.listen(8081); proxyServer.listen(8081);