vh

0.0.2 • Public • Published

vh

A tiny and fast vhost hash router for http/https/spdy

Installation

$ npm install vh

Usage

 
var http = require('http'),
    vh = require('vh');
 
http.createServer(
    vh()
        .when('domain.com', app1)
        .when('*.domain.com', app2)
        .otherwise(appNotFound)
);
 
function app1(req, res) {
    res.writeHead(200, { 'Content-Type': 'text/plain' });
    res.end('Application 1');
}
 
function app2(req, res) {
    res.writeHead(200, { 'Content-Type': 'text/plain' });
    res.end('Application 2');
}
 
function appNotFound(req, res) {
    res.writeHead(200, { 'Content-Type': 'text/plain' });
    res.end('No Application Found');
}
 

Readme

Keywords

none

Package Sidebar

Install

npm i vh

Weekly Downloads

2

Version

0.0.2

License

none

Last publish

Collaborators

  • e2tox