set-channel.js 531 Bytes
/**
 * 设置频道
 * @author: 赵彪<bill.zhao@yoho.cn>
 * @date: 2016/6/16
 */

'use strict';

module.exports = () => {
    return (req, res, next) => {
        if (!req.xhr) {
            const obj = {};
            const channel = req.query.channel || req.cookies._Channel || 'boys';

            obj[channel] = true;

            Object.assign(res.locals, {
                pageChannel: obj
            });

            req.yoho.channel = channel;
            res.yoho.channel = channel;
        }

        next();
    };
};