mcavage/node-restify — pull request #657 by amarnus (2014-08-05 15:37:50+00:00)
Title: Isolated host-based routes in a single Restify server

The idea is to allow a single Restify server to serve multiple "sites", each with their separate set of routes, based on the `Host` header of the incoming web request. The problem with building something like that with Restify as of its current version is that all routes are by default, shared by all the "sites" served from the same server.

These changes provide a way by which you can opt-in to Host-based routing in a Restify app. To do this, you need to tag your routes with the host that it should be mapped to:

```javascript
server.get({ path: '/one', host: 'one.example.com' }, function(req, res, next) {
res.end('One!');
next();
});
server.get({ path: '/two', host: 'two.example.com' }, function(req, res, next) {
res.end('Two!');
next();
});
```

So, if you request `http://one.example.com/two`, or `http://two.example.com/one`, you'll get a `404`.

To implement this change, I have:

- changed the cache key only for the routes for which the host has been specified
- changed the schema of `reverse` from `reverse[route-source][http-method]` to `reverse[host][route-source][http-method`. The default host is `*`.

The idea is to not affect sites that don't opt-in, in any way.