index.js
function vhost (hostname, 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) {
    var vhostdata = vhostof(req, regexp)

    if (!vhostdata) {
      return next()
    }

    // populate
    req.vhost = vhostdata

    // handle
    handle(req, res, next)
  }
}
function vhost (hostname, 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) {
    var vhostdata = vhostof(req, regexp)

    if (!vhostdata) {
      return next()
    }

    // populate
    req.vhost = vhostdata

    // handle
    handle(req, res, next)
  }
}
function vhost ( hostname , 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 ) { var vhostdata = vhostof ( req , regexp ) if ( ! vhostdata ) { return next ( ) } // populate req . vhost = vhostdata // handle handle ( req , res , next ) } }
Create a vhost middleware.

@param {string|RegExp} hostname
@param {function} handle
@return {Function}
@public
Create a vhost middleware .