Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added mounting example

  • Loading branch information...
commit 8d525a18b35c02b3f6313ae082f52e0bfb9744ef 1 parent 2a9bf65
@tj tj authored
Showing with 33 additions and 0 deletions.
  1. +33 −0 examples/mounting.js
View
33 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);
Please sign in to comment.
Something went wrong with that request. Please try again.