molecule
molecule copied to clipboard
Virtual Host middleware
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.