实现了bridge接口

This commit is contained in:
Xu Chang 2023-06-09 17:46:47 +08:00
parent 5d91dace5a
commit 650bf2333f
2 changed files with 20 additions and 0 deletions

View File

@ -71,6 +71,15 @@ async function startup(path, contextBuilder, connector, omitWatchers, omitTimers
ctx.response.body = body;
return;
});
// 桥接访问外部资源的入口
router.get(connector.getBridgeRouter(), async (ctx) => {
const { request: { querystring }, response } = ctx;
const { url, headers } = connector.parseBridgeRequestQuery(querystring);
// headers待处理
const res = await fetch(url);
response.body = res.body;
return;
});
// 注入所有的endpoints
const endpoints = appLoader.getEndpoints();
const endpointsArray = [];

View File

@ -81,6 +81,17 @@ export async function startup<ED extends EntityDict & BaseEntityDict, Cxt extend
return;
});
// 桥接访问外部资源的入口
router.get(connector.getBridgeRouter(), async (ctx) => {
const { request: { querystring }, response } = ctx;
const { url, headers } = connector.parseBridgeRequestQuery(querystring);
// headers待处理
const res = await fetch(url as string);
response.body = res.body;
return;
});
// 注入所有的endpoints
const endpoints = appLoader.getEndpoints();
const endpointsArray: [string, string, string][] = [];