...
|
...
|
@@ -62,10 +62,10 @@ const handlerError = (err = {}, req, res, next) => { |
|
|
return next(err);
|
|
|
};
|
|
|
|
|
|
const getCacheKey = (urlPath, cackeKey = '') => {
|
|
|
const getCacheKey = (urlPath, cacheKey = '') => {
|
|
|
const urlObj = url.parse(urlPath);
|
|
|
|
|
|
return md5(cackeKey
|
|
|
return md5(cacheKey
|
|
|
.replace('$url', urlObj.pathname)
|
|
|
.replace('$params', urlObj.query));
|
|
|
};
|
...
|
...
|
@@ -84,7 +84,7 @@ const render = (route) => { |
|
|
if (isDegrade) {
|
|
|
return res.send(degradeHtml);
|
|
|
}
|
|
|
const ck = route.cackeKey ? getCacheKey(req.url, route.cackeKey) : void 0;
|
|
|
const ck = route.cacheKey ? getCacheKey(req.url, route.cacheKey) : void 0;
|
|
|
|
|
|
if (config.useCache && route.cache && ck) {
|
|
|
const html = await redis.getAsync(ck);
|
...
|
...
|
@@ -116,7 +116,7 @@ const devRender = (route) => { |
|
|
return async(req, res, next) => {
|
|
|
try {
|
|
|
res.setHeader('X-YOHO-Version', pkg.version);
|
|
|
const ck = route.cackeKey ? getCacheKey(req.url, route.cackeKey) : void 0;
|
|
|
const ck = route.cacheKey ? getCacheKey(req.url, route.cacheKey) : void 0;
|
|
|
|
|
|
// return require('request-promise')({
|
|
|
// url: 'http://m.yohobuy.com:6005/degrade.html'
|
...
|
...
|
|