Authored by 郭成尧

'shop-domain-support'

@@ -38,6 +38,7 @@ global.utils = path.resolve('./utils'); @@ -38,6 +38,7 @@ global.utils = path.resolve('./utils');
38 38
39 const logger = global.yoho.logger; 39 const logger = global.yoho.logger;
40 40
  41 +app.set('subdomain offset', 3);
41 app.set('view engine', '.hbs'); 42 app.set('view engine', '.hbs');
42 app.set('views', './doraemon/views'); 43 app.set('views', './doraemon/views');
43 app.engine('.hbs', hbs({ 44 app.engine('.hbs', hbs({
@@ -82,6 +83,7 @@ app.use((req, res, next) => { @@ -82,6 +83,7 @@ app.use((req, res, next) => {
82 83
83 // dispatcher 84 // dispatcher
84 try { 85 try {
  86 + const shopCheck = require('./doraemon/middleware/shop-check');
85 const user = require('./doraemon/middleware/user'); 87 const user = require('./doraemon/middleware/user');
86 const setYohoData = require('./doraemon/middleware/set-yoho-data'); 88 const setYohoData = require('./doraemon/middleware/set-yoho-data');
87 const errorHanlder = require('./doraemon/middleware/error-handler'); 89 const errorHanlder = require('./doraemon/middleware/error-handler');
@@ -89,6 +91,7 @@ try { @@ -89,6 +91,7 @@ try {
89 91
90 92
91 // YOHO 前置中间件 93 // YOHO 前置中间件
  94 + app.use(shopCheck());
92 app.use(setYohoData()); 95 app.use(setYohoData());
93 app.use(user()); 96 app.use(user());
94 app.use(setPageInfo()); 97 app.use(setPageInfo());
  1 +/**
  2 + * Created by PhpStorm.
  3 + * User: Targaryen
  4 + * Date: 2016/8/29
  5 + * Time: 15:27
  6 + */
  7 +'use strict';
  8 +
  9 +module.exports = () => {
  10 +
  11 + return (req, res, next) => {
  12 + if (req.subdomains.length) {
  13 + req.url = '/product/index/brand?domain=' + req.subdomains[0];
  14 + }
  15 +
  16 + next();
  17 + };
  18 +
  19 +};