middleware/mw.app.context.js
function init(ctx) {
        var domainMap = getDomainMap();

        // for each request we need to set the proper context
        ctx.server.ext('onRequest', function (req, reply) {
            setLanguage(req);
            setAppInfo(req, domainMap);

            var appName = req.app.name;
            var lang = req.app.lang;
            if (req.app.isLegacyMobile || appName === 'www' || req.app.domain === 'contact') {
                appName = appName === 'www' ? 'contact' : appName;
                reply.redirect(routeHelper.getBaseUrl(appName, lang) + req.url.path).permanent(true);
                return;
            }

            setContext(req);
            reply.continue();
        });

        return new Q(ctx);
    }
function init(ctx) {
        var domainMap = getDomainMap();

        // for each request we need to set the proper context
        ctx.server.ext('onRequest', function (req, reply) {
            setLanguage(req);
            setAppInfo(req, domainMap);

            var appName = req.app.name;
            var lang = req.app.lang;
            if (req.app.isLegacyMobile || appName === 'www' || req.app.domain === 'contact') {
                appName = appName === 'www' ? 'contact' : appName;
                reply.redirect(routeHelper.getBaseUrl(appName, lang) + req.url.path).permanent(true);
                return;
            }

            setContext(req);
            reply.continue();
        });

        return new Q(ctx);
    }
function init ( ctx ) { var domainMap = getDomainMap ( ) ; // for each request we need to set the proper context ctx . server . ext ( 'onRequest' , function ( req , reply ) { setLanguage ( req ) ; setAppInfo ( req , domainMap ) ; var appName = req . app . name ; var lang = req . app . lang ; if ( req . app . isLegacyMobile || appName === 'www' || req . app . domain === 'contact' ) { appName = appName === 'www' ? 'contact' : appName ; reply . redirect ( routeHelper . getBaseUrl ( appName , lang ) + req . url . path ) . permanent ( true ) ; return ; } setContext ( req ) ; reply . continue ( ) ; } ) ; return new Q ( ctx ) ; }
Figure out the language and target app
@param ctx
@returns {Q}
Figure out the language and target app