Skip to content

Commit

Permalink
updating demo
Browse files Browse the repository at this point in the history
  • Loading branch information
Marak committed Jul 27, 2010
1 parent 2f49810 commit c4b7c0d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 99 deletions.
48 changes: 24 additions & 24 deletions demo.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,48 +8,48 @@

var vows = require('vows'),
sys = require('sys'),
colors = require('./vendor/colors')
colors = require('colors')
assert = require('assert'),
http = require('http');

var HttpProxy = require('./lib/node-http-proxy').HttpProxy;
var testServers = {};


// regular http server
// ascii art from http://github.com/marak/asciimo
var welcome = '\
# # ##### ##### ##### ##### ##### #### # # # # \n\
# # # # # # # # # # # # # # # # \n\
###### # # # # ##### # # # # # # ## # \n\
# # # # ##### ##### ##### # # ## # \n\
# # # # # # # # # # # # # \n\
# # # # # # # # #### # # # \n';
sys.puts(welcome.rainbow.bold);

// create regular http proxy server
http.createServer(function (req, res){
// Initialize the nodeProxy and start proxying the request
var proxy = new (HttpProxy);
proxy.init(req, res);
// lets proxy the request to another service
proxy.proxyRequest('localhost', '8081', req, res);

}).listen(8080);
sys.puts('started a http server on port 8080'.green)
proxy.proxyRequest('localhost', '9000', req, res);
}).listen(8000);
sys.puts('http proxy server'.blue + ' started '.green.bold + 'on port '.blue + '8000'.yellow);

// http server with latency
// http proxy server with latency
http.createServer(function (req, res){
// Initialize the nodeProxy and start proxying the request
var proxy = new (HttpProxy);
proxy.init(req, res);

// lets proxy the request to another service
setTimeout(function(){
proxy.proxyRequest('localhost', '8090', req, res);
proxy.proxyRequest('localhost', '9000', req, res);
}, 200)

}).listen(8081);
sys.puts('started a http server with latency on port 8081'.green)


}).listen(8001);
sys.puts('http proxy server '.blue + 'started '.green.bold + 'on port '.blue + '8001 '.yellow + 'with latency'.magenta.underline );

// create regular http server
http.createServer(function (req, res){
res.writeHead(200, {'Content-Type': 'text/plain'});
res.write('foo');
res.end();
}).listen(8090);
sys.puts('started another http server on port 8090'.green)


sys.puts('to test the proxy server, request http://localhost:8080/ in your browser.');
sys.puts('your request will proxy to the server running on port 8081');
}).listen(9000);
sys.puts('http server '.blue + 'started '.green.bold + 'on port '.blue + '9000 '.yellow);
//sys.puts('to test the proxy server, request http://localhost:8080/ in your browser.');
//sys.puts('your request will proxy to the server running on port 8081');
75 changes: 0 additions & 75 deletions vendor/colors.js

This file was deleted.

0 comments on commit c4b7c0d

Please sign in to comment.