Permalink
Browse files

relative requires, halfway done with the readme

  • Loading branch information...
1 parent 00941a1 commit 243692239a9c29480602b5d9d7a6fe99c9adc2a4 @substack committed Dec 15, 2012
Showing with 36 additions and 32 deletions.
  1. +9 −2 bench/bench.js
  2. +0 −7 bench/bouncy.js
  3. +1 −1 example/bounce.js
  4. +1 −1 example/https.js
  5. +6 −2 example/route.js
  6. +1 −1 example/stream.js
  7. +18 −18 readme.markdown
View
@@ -1,8 +1,8 @@
#!/usr/bin/env node
var name = process.argv[2];
-var p0 = 7000;
-var p1 = 7001;
+var p0 = 7500;
+var p1 = 7501;
var proxy = require('./' + name)(p1);
proxy.listen(p0);
@@ -14,3 +14,10 @@ var server = http.createServer(function (req, res) {
server.listen(p1);
console.log('ab -n 5000 -c 10 http://localhost:' + p0 + '/');
+
+setInterval(function () {
+ var mb = process.memoryUsage().heapTotal / 1024 / 1024;
+ var s = String(Math.round(mb * 10) / 10);
+ var pad = Array(Math.max(1, 6 - s.length + 1)).join(' ');
+ console.log(pad + s + ' M');
+}, 2000);
View
@@ -3,10 +3,3 @@ var bouncy = require('../');
module.exports = function (port) {
return bouncy(function (req, bounce) { bounce(port) });
};
-
-setInterval(function () {
- var mb = process.memoryUsage().heapTotal / 1024 / 1024;
- var s = String(Math.round(mb * 10) / 10);
- var pad = Array(Math.max(1, 6 - s.length + 1)).join(' ');
- console.log(pad + s + ' M');
-}, 1000);
View
@@ -1,6 +1,6 @@
// bounce requests received on :8001 along to :8000
-var bouncy = require('bouncy');
+var bouncy = require('../');
bouncy(function (req, bounce) {
bounce(8000);
View
@@ -4,7 +4,7 @@ var opts = {
cert : fs.readFileSync(__dirname + '/https/certificate.pem')
};
-var bouncy = require('bouncy');
+var bouncy = require('../');
bouncy(opts, function (req, bounce) {
bounce(9000);
}).listen(7005);
View
@@ -1,10 +1,14 @@
-var bouncy = require('bouncy');
+var bouncy = require('../');
-bouncy(function (req, bounce) {
+bouncy(function (req, res, bounce) {
if (req.headers.host === 'beep.example.com') {
bounce(8001);
}
else if (req.headers.host === 'boop.example.com') {
bounce(8002);
}
+ else {
+ res.statusCode = 404;
+ res.end('no such host');
+ }
}).listen(8000);
View
@@ -1,6 +1,6 @@
// bounce requests to :8001 along to :8000
-var bouncy = require('bouncy');
+var bouncy = require('../');
var net = require('net');
bouncy(function (req, bounce) {
View
@@ -1,41 +1,41 @@
-bouncy
-======
+# bouncy
-Bouncy uses node's http parser innards to bounce http requests around to where
-they need to go in an entirely transparent way.
+route http requests to other hosts
-Use bouncy as a load balancer or http host router, either programmatically or
-with the simple command-line tool.
-
-Bouncy is websocket and tls (https) capable.
+bouncy uses [http-raw](http://github.com/substack/http-raw) to extend the core
+node http apis with fully transparent streaming without resulting to
+re-normalizing the requests.
[![build status](https://secure.travis-ci.org/substack/bouncy.png)](http://travis-ci.org/substack/bouncy)
![trampoline](http://substack.net/images/trampoline.png)
-example
-=======
+# example
-route.js
---------
+## route.js
Route requests based on the host field
-````javascript
+``` js
var bouncy = require('bouncy');
-bouncy(function (req, bounce) {
+var server = bouncy(function (req, res, bounce) {
if (req.headers.host === 'beep.example.com') {
bounce(8001);
}
else if (req.headers.host === 'boop.example.com') {
bounce(8002);
}
-}).listen(8000);
-````
+ else {
+ res.statusCode = 404;
+ res.end('no such host');
+ }
+});
+server.listen(8000);
+```
+
-command-line
-============
+# command-line
Just create a `routes.json` file like this:

0 comments on commit 2436922

Please sign in to comment.