From 8fc8d966c4681d514af00516b348105608e13382 Mon Sep 17 00:00:00 2001 From: Charlie McConnell Date: Wed, 21 Sep 2011 14:11:41 -0700 Subject: [PATCH] [examples] Updated examples to v0.7.x API. --- examples/websocket/latent-websocket-proxy.js | 16 +++++++--------- examples/websocket/standalone-websocket-proxy.js | 15 +++++++-------- 2 files changed, 14 insertions(+), 17 deletions(-) diff --git a/examples/websocket/latent-websocket-proxy.js b/examples/websocket/latent-websocket-proxy.js index 3598ca9..85a06a9 100644 --- a/examples/websocket/latent-websocket-proxy.js +++ b/examples/websocket/latent-websocket-proxy.js @@ -67,12 +67,14 @@ socket.on('connection', function (client) { // // Setup our server to proxy standard HTTP requests // -var proxy = new httpProxy.HttpProxy(); -var proxyServer = http.createServer(function (req, res) { - proxy.proxyRequest(req, res, { +var proxy = new httpProxy.HttpProxy({ + target: { host: 'localhost', 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); setTimeout(function () { - proxy.proxyWebSocketRequest(req, socket, head, { - port: 8080, - host: 'localhost', - buffer: buffer - }); + proxy.proxyWebSocketRequest(req, socket, head, buffer); }, 1000); }); diff --git a/examples/websocket/standalone-websocket-proxy.js b/examples/websocket/standalone-websocket-proxy.js index fdefa6d..c173405 100644 --- a/examples/websocket/standalone-websocket-proxy.js +++ b/examples/websocket/standalone-websocket-proxy.js @@ -67,12 +67,14 @@ socket.on('connection', function (client) { // // Setup our server to proxy standard HTTP requests // -var proxy = new httpProxy.HttpProxy(); -var proxyServer = http.createServer(function (req, res) { - proxy.proxyRequest(req, res, { +var proxy = new httpProxy.HttpProxy({ + target: { host: 'localhost', 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. // proxyServer.on('upgrade', function (req, socket, head) { - proxy.proxyWebSocketRequest(req, socket, head, { - port: 8080, - host: 'localhost' - }); + proxy.proxyWebSocketRequest(req, socket, head); }); proxyServer.listen(8081);