Skip to content

Commit

Permalink
Added mounting example
Browse files Browse the repository at this point in the history
  • Loading branch information
tj committed Feb 28, 2011
1 parent 2a9bf65 commit 8d525a1
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions examples/mounting.js
@@ -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.