2.0.2 • Published 6 years ago
servie-vhost v2.0.2
Servie Vhost
Simple virtual host middleware for Servie.
Installation
npm install servie-vhost --saveUsage
import { vhost, getHostFromUrl } from "servie-vhost";
import { compose } from "throwback";
const app = compose([
vhost("admin.example.com", function(req) {
return send(req, "Welcome to admin!");
}),
vhost(":subdomain.example.com", function(req) {
return send(req, `Welcome to ${req.vhost[0]} subdomain!`);
})
]);For projects whose host is not in the header, they can switch between exported getHostFromHeader and getHostFromUrl functions, or define their own, as the third argument to vhost(hostname, fn, getHost).
TypeScript
This project is written using TypeScript and publishes the definitions directly to NPM.
License
Apache 2.0