feat: 支持 /api/open 前缀的开放api

This commit is contained in:
苏文雄 2019-04-22 14:57:51 +08:00
parent 140e9f1eb7
commit 50f9a58e56
2 changed files with 5 additions and 2 deletions

View File

@ -56,7 +56,8 @@ class baseController {
let params = Object.assign({}, ctx.query, ctx.request.body);
let token = params.token;
if (token && openApiRouter.indexOf(ctx.path) > -1) {
// 如果前缀是 /api/open执行 parse token 逻辑
if (token && (openApiRouter.indexOf(ctx.path) > -1 || ctx.path.indexOf('/api/open/') === 0 )) {
let tokens = parseToken(token)
const oldTokenUid = '999999'

View File

@ -588,7 +588,9 @@ function addPluginRouter(config) {
throw new Error('Plugin Route config Error');
}
let method = config.method || 'GET';
let routerPath = '/plugin/' + config.path;
// let routerPath = '/plugin/' + config.path;
// 支持 /api/open/plugin 前缀的 openApi
let routerPath = (config.prefix || '') + '/plugin/' + config.path;
if (pluginsRouterPath.indexOf(routerPath) > -1) {
throw new Error('Plugin Route path conflict, please try rename the path');
}