Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

updated bounce.js example with inline http server

  • Loading branch information...
commit a1cae82ef48ff511a9375a418fdc81ff0a179ff6 1 parent 9914a4a
@substack authored
Showing with 14 additions and 5 deletions.
  1. +13 −4 example/bounce.js
  2. +1 −1  readme.markdown
View
17 example/bounce.js
@@ -1,7 +1,16 @@
-// bounce requests received on :8001 along to :8000
-
var bouncy = require('../');
+var http = require('http');
+
+bouncy(function (req, res, bounce) {
+ if (req.headers.host === 'robot') {
+ bounce(8001);
+ }
+ else {
+ res.statusCode = 404;
+ res.end('not found\n');
+ }
+}).listen(8000);
-bouncy(function (req, bounce) {
- bounce(8000);
+http.createServer(function (req, res) {
+ res.end('beep boop\n');
}).listen(8001);
View
2  readme.markdown
@@ -17,7 +17,7 @@ without doing anything special.
## route.js
-Route requests based on the host field
+Route requests based on the host field to servers on ports 8001 and 8002:
``` js
var bouncy = require('bouncy');
Please sign in to comment.
Something went wrong with that request. Please try again.