Authored by 郭成尧

'shop-domain-support'

... ... @@ -38,6 +38,7 @@ global.utils = path.resolve('./utils');
const logger = global.yoho.logger;
app.set('subdomain offset', 3);
app.set('view engine', '.hbs');
app.set('views', './doraemon/views');
app.engine('.hbs', hbs({
... ... @@ -82,6 +83,7 @@ app.use((req, res, next) => {
// dispatcher
try {
const shopCheck = require('./doraemon/middleware/shop-check');
const user = require('./doraemon/middleware/user');
const setYohoData = require('./doraemon/middleware/set-yoho-data');
const errorHanlder = require('./doraemon/middleware/error-handler');
... ... @@ -89,6 +91,7 @@ try {
// YOHO 前置中间件
app.use(shopCheck());
app.use(setYohoData());
app.use(user());
app.use(setPageInfo());
... ...
/**
* Created by PhpStorm.
* User: Targaryen
* Date: 2016/8/29
* Time: 15:27
*/
'use strict';
module.exports = () => {
return (req, res, next) => {
if (req.subdomains.length) {
req.url = '/product/index/brand?domain=' + req.subdomains[0];
}
next();
};
};
... ...