nl_tokens: Create a vhost middleware . subsite should = IS_ROUTE when callled from a router ( app . use ) since Router will already have subsite / base
pl_tokens: 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 <mask> ( req , res , next ) } }