perf: 支持部署到阿里云云原生API网关、AI网关

This commit is contained in:
xiaojunnuo
2025-08-28 00:36:28 +08:00
parent 17f23f3751
commit 2ca20be197
5 changed files with 292 additions and 8 deletions

View File

@@ -7,9 +7,9 @@ export type AliyunClientV2Req = {
// 接口 HTTP 方法
method?: "GET" | "POST";
authType?: "AK";
style?: "RPC";
style?: "RPC" | "ROA";
// 接口 PATH
pathname?: `/`;
pathname?: string;
data?: any;
};
@@ -63,10 +63,10 @@ export class AliyunClientV2 {
protocol: "HTTPS",
// 接口 HTTP 方法
method: req.method ?? "POST",
authType: "AK",
style: "RPC",
authType: req.authType ?? "AK",
style: req.style ?? "RPC",
// 接口 PATH
pathname: `/`,
pathname: req.pathname ?? `/`,
// 接口请求体内容格式
reqBodyType: "json",
// 接口响应体内容格式

View File

@@ -9,7 +9,8 @@ export type AliyunCertInfo = {
export type AliyunSslClientOpts = {
access: AliyunAccess;
logger: ILogger;
endpoint: string;
endpoint?: string;
region?: string;
};
export type AliyunSslGetResourceListReq = {
@@ -48,10 +49,19 @@ export class AliyunSslClient {
async getClient() {
const access = this.opts.access;
const client = new AliyunClient({ logger: this.opts.logger });
let endpoint = this.opts.endpoint || "cas.aliyuncs.com";
if (this.opts.endpoint == null && this.opts.region) {
if (this.opts.region === "cn-hangzhou") {
endpoint = "cas.aliyuncs.com";
} else {
endpoint = `cas.${this.opts.region}.aliyuncs.com`;
}
}
await client.init({
accessKeyId: access.accessKeyId,
accessKeySecret: access.accessKeySecret,
endpoint: `https://${this.opts.endpoint || "cas.aliyuncs.com"}`,
endpoint: `https://${endpoint}`,
apiVersion: "2020-04-07",
});
return client;