• This project
    • Loading...
  • Sign in

fe / yohobuywap-node · Files

Go to a project

GitLab

  • Go to group
  • Project
  • Activity
  • Files
  • Commits
  • Pipelines 0
  • Builds 0
  • Graphs
  • Milestones
  • Issues 0
  • Merge Requests 0
  • Members
  • Labels
  • Wiki
  • Forks
  • Network
  • Create a new issue
  • yohobuywap-node
  • doraemon
  • middleware
  • set-pageinfo.js
  • add set page info middleware
    a7d35272
    by biao
    2016-06-22 15:13:47 +0800  
    Browse Files
set-pageinfo.js 418 Bytes
Raw Blame History Permalink
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
/**
 * 设置页面的module,page默认值
 * @author: 赵彪<bill.zhao@yoho.cn>
 * @date: 2016/6/22
 */

'use strict';

module.exports = () => {
    return (req, res, next) => {
        if (!req.xhr) {
            const arr = req.path.substring(1).split('/');

            Object.assign(res.locals, {
                module: arr[0],
                page: arr[1]
            });
        }

        next();
    };
};