server/helpers/vhost.js
function vhost (hostname, subsite, handle) {
  if (!hostname) {
    throw new TypeError('argument hostname is required')
  }

  if (!handle) {
    throw new TypeError('argument handle is required')
  }

  if (typeof handle !== 'function') {
    throw new TypeError('argument handle must be a function')
  }

  // create regular expression for hostname
  var regexp = hostregexp(hostname)

  return function vhost (req, res, next) {
    if (res.locals.zlSite && res.locals.zlSite.zsBaseUrlPath && !subsite) {
      return next()
    }

    var vhostdata = vhostof(req, regexp, subsite)

    if (!vhostdata) {
      return next()
    }

    // populate
    req.vhost = vhostdata

    // handle
    handle(req, res, next)
  }
}
function vhost (hostname, subsite, handle) {
  if (!hostname) {
    throw new TypeError('argument hostname is required')
  }

  if (!handle) {
    throw new TypeError('argument handle is required')
  }

  if (typeof handle !== 'function') {
    throw new TypeError('argument handle must be a function')
  }

  // create regular expression for hostname
  var regexp = hostregexp(hostname)

  return function vhost (req, res, next) {
    if (res.locals.zlSite && res.locals.zlSite.zsBaseUrlPath && !subsite) {
      return next()
    }

    var vhostdata = vhostof(req, regexp, subsite)

    if (!vhostdata) {
      return next()
    }

    // populate
    req.vhost = vhostdata

    // handle
    handle(req, res, next)
  }
}
Create a vhost middleware.
subsite should = 'IS_ROUTE' when callled from a router (app.use) since Router
will already have subsite/base

@param {string|RegExp} hostname
@param {function} handle
@return {Function}
@public