Skip to content
Browse files

route example

  • Loading branch information...
1 parent 67665b5 commit ff8c99e78aa37ba68f696cf7141e6019875a09be @substack committed
Showing with 29 additions and 1 deletion.
  1. +19 −1 README.markdown
  2. +10 −0 example/route.js
View
20 README.markdown
@@ -9,10 +9,28 @@ Use bouncy as a load balancer or http host router.
example
=======
+route.js
+--------
+
+Route requests based on the host field
+
+````javascript
+var bouncy = require('bouncy');
+
+bouncy(function (req, bounce) {
+ if (req.headers.host === 'beep.example.com') {
+ bounce(8001);
+ }
+ else if (req.headers.host === 'boop.example.come') {
+ bounce(8002)
+ }
+}).listen(8000);
+````
+
bounce.js
---------
-Bounce requests received on :8001 along to :8000...
+Bounce all requests received on :8001 along to :8000
````javascript
var bouncy = require('bouncy');
View
10 example/route.js
@@ -0,0 +1,10 @@
+var bouncy = require('bouncy');
+
+bouncy(function (req, bounce) {
+ if (req.headers.host === 'beep.example.com') {
+ bounce(8001);
+ }
+ else if (req.headers.host === 'boop.example.come') {
+ bounce(8002)
+ }
+}).listen(8000);

0 comments on commit ff8c99e

Please sign in to comment.
Something went wrong with that request. Please try again.