molecule icon indicating copy to clipboard operation
molecule copied to clipboard

Virtual Host middleware

Open testinfected opened this issue 10 years ago • 0 comments

A middleware to hand off processing to a different application when the host of the request matches a given hostname.

So we can write, e.g.:

Application serveAssets = new StaticAssets(new FileServer(new File("./public")), "/");
server.use(new VirtualHost("assets.example.com", serveAssets));
// add middlewares for main app
// ...
server.start(...); // the main app

Hostname to match can be specified as a string or a RegExp:

  • When hostname is a string, it can contain * to match 1 or more characters in that section of the hostname
  • When hostname is a RegExp, it will be forced to match based on the start and end of the hostname
  • Match is case insensitive, since hostnames are.

testinfected avatar Oct 06 '14 23:10 testinfected