Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More

simple-virtual-hosts

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

simple-virtual-hosts

A simple hostname router

  • 0.0.1
  • npm
  • Socket score

Version published
Maintainers
1
Created

simple-virtual-hosts

A simple hostname router

Example

'use strict';

var VirtualHosts = require('simple-virtual-hosts');

var vhost = new VirtualHosts()
	.when('example.com', serveWeb)
	.when('api.example.com', serveApi)
	.default(serveDefault);

require('http')
	.createServer(vhost.dispatch)
	.listen(10000);

function serveWeb (req, res) {
	console.log('web!');
	res.statusCode = 200;
	res.end();
}

function serveApi (req, res) {
	console.log('api!');
	res.statusCode = 200;
	res.end();
}

function serveDefault (req, res) {
	console.log('default!');
	res.statusCode = 200;
	res.end();
}

FAQs

Package last updated on 24 Feb 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts