Permalink
Browse files

Added mounting example

  • Loading branch information...
1 parent 2a9bf65 commit 8d525a18b35c02b3f6313ae082f52e0bfb9744ef @tj tj committed Feb 28, 2011
Showing with 33 additions and 0 deletions.
  1. +33 −0 examples/mounting.js
View
@@ -0,0 +1,33 @@
+
+/**
+ * Module dependencies.
+ */
+
+var connect = require('../');
+
+var blog = connect(
+ connect.router(function(app){
+ app.get('/', function(req, res){
+ res.end('list blog posts. try /post/0');
+ });
+
+ app.get('/post/:id', function(req, res){
+ res.end('got post ' + req.params.id);
+ });
+ })
+);
+
+var admin = connect(
+ connect.basicAuth(function(user, pass){ return 'tj' == user && 'tobi' == pass })
+ , function(req, res){
+ res.end('admin stuff');
+ }
+);
+
+connect()
+ .use('/admin', admin)
+ .use('/blog', blog)
+ .use(function(req, res){
+ res.end('try /blog, /admin, or /blog/post/0');
+ })
+ .listen(3000);

0 comments on commit 8d525a1

Please sign in to comment.