0.0.3 • Published 10 years ago

vhost-koa v0.0.3

Weekly downloads
2
License
MIT
Repository
github
Last release
10 years ago

koa-vhost

A vhost middleware for koa application.

Forked from koa-vhost

Install

npm i vhost-koa --save

or install from github

npm i JiangJie/koa-vhost --save

Example

let koa = require('koa');
let mount = require('koa-mount');
let Router = require('koa-router');
let vhost = require('vhost-koa');

let app = koa();

let vhosts = ['127.0.0.1', 'localhost'];

vhosts = vhosts.map(function(item) {
try {
  let vapp = koa();

  let API = new Router();
  API.get('/', function*() {this.body = 'hello';});
  vapp.use(mount('/', API.middleware()));
  return {
    host: item,
    app: vapp
  };
} catch(e) {
  console.log('vhost error %s', e.message);
  return;
}
}).filter(function(item) {
    return !!item;
});
app.use(vhost(vhosts));
0.0.3

10 years ago

0.0.2

10 years ago

0.0.1

10 years ago