title: Express.js - How can I pass a url param from the main router to another router module?
body: <p>In my small chat application, when I make a HTTP call to an endpoint ending in "users" I want my room router to take over. This be with a preceding room name, or with nothing at all.</p>
  
  <p>routes.js:</p>
  
  <pre><code>module.exports = function(app) {
      var roomRoute = require('./routes/room');
      app.use('/:roomname/users', roomRoute);
      app.use('/users', roomRoute);
  };
  </code></pre>
  
  <p>Now when my room router takes over, I want to be able to access the room name if it exists in the url. Something like:</p>
  
  <p>./routes/room.js:</p>
  
  <pre><code>var express = require('express');
  var router = express.Router();
  
  router.get('/info', function(req, res) {
      console.log('the roomname is ' + req.roomname);
      res.end();
  });
  
  module.exports = router;
  </code></pre>
  
  <p>Is there any way to easily pass this room name along? I could probably extract it from the baseUrl but I think there is probably a better way...</p>