添加网关路由。
调试
您可以在OpenAPI Explorer中直接运行该接口,免去您计算签名的困扰。运行成功后,OpenAPI Explorer可以自动生成SDK代码示例。
调试
授权信息
|
操作 |
访问级别 |
资源类型 |
条件关键字 |
关联操作 |
|
mse:AddGatewayRoute |
create |
*Gateway
|
无 | 无 |
请求参数
|
名称 |
类型 |
必填 |
描述 |
示例值 |
| GatewayId |
integer |
否 |
网关 ID。 |
526 |
| Name |
string |
是 |
路由名称。 |
test |
| RouteOrder |
integer |
否 |
路由顺序。(数值越小优先级越高) |
1 |
| Predicates |
array |
否 |
匹配规则。 |
|
| PathPredicates |
object |
否 |
路由匹配。 |
|
| Path |
string |
否 |
路径。 |
/test |
| Type |
string |
否 |
路由匹配:
|
PRE |
| IgnoreCase |
boolean |
否 |
忽略大小写。 |
true |
| MethodPredicates |
array |
否 |
方法匹配。 |
|
|
string |
否 |
具体方法。 |
GET |
|
| HeaderPredicates |
array |
否 |
请求头匹配。 |
|
|
object |
否 |
请求头。 |
||
| Key |
string |
否 |
请求头 Key。 |
debug |
| Value |
string |
否 |
对应的 Value。 |
test |
| Type |
string |
否 |
匹配类型。 |
PRE |
| QueryPredicates |
array |
否 |
URL 参数匹配。 |
|
|
object |
否 |
URL 参数。 |
||
| Key |
string |
否 |
参数名。 |
userid |
| Value |
string |
否 |
匹配值。 |
test |
| Type |
string |
否 |
匹配类型。 |
PRE |
| Services |
array |
否 |
服务列表(路由指向为单服务、多服务、标签路由时填写)。 |
|
|
array |
否 |
服务列表。 |
||
| ServiceId |
integer |
否 |
服务 ID。 |
353 |
| Percent |
integer |
否 |
当前服务/服务版本分流百分比(只在使用多服务、标签路由时填写)。 |
80 |
| Version |
string |
否 |
服务版本(只在使用标签路由时填写)。 |
v1 |
| Name |
string |
否 |
名称。 |
user |
| SourceType |
string |
否 |
来源类型。 |
MSE |
| Namespace |
string |
否 |
服务所在命名空间。 |
default |
| GroupName |
string |
否 |
服务分组名称。 |
test |
| AgreementType |
string |
否 |
协议类型。 |
DUBBO |
| HttpDubboTranscoder |
object |
否 |
Dubbo 协议转换体。 |
|
| DubboServiceName |
string |
否 |
Dubbo 服务名称。 |
org.apache.dubbo.samples.basic.api.DemoService |
| DubboServiceVersion |
string |
否 |
Dubbot 服务版本。 |
0.0.0 |
| DubboServiceGroup |
string |
否 |
服务组。 |
group |
| MothedMapList |
array |
否 |
Dubbo 转发规则列表。 |
|
|
array |
否 |
方法映射。 |
||
| DubboMothedName |
string |
否 |
Dubbo 方法名。 |
sayHello |
| HttpMothed |
string |
否 |
HTTP 方法。 说明
支持 HTTP 方法参数值。
|
ALL_GET |
| Mothedpath |
string |
否 |
方法匹配路径。 |
/mytestzbk/sayhello |
| PassThroughAllHeaders |
string |
否 |
Header 透传类型。 说明
透传类型枚举值。
|
PASS_NOT |
| PassThroughList |
array |
否 |
指定透传 Header 列表 |
|
|
string |
否 |
指定 Header 透传值。 |
x-forward |
|
| ParamMapsList |
array |
否 |
参数映射列表。 |
|
|
object |
否 |
参数映射体。 |
||
| ExtractKeySpec |
string |
否 |
入参位置。 说明
入参位置枚举值。
|
ALL_QUERY_PARAMETER |
| ExtractKey |
string |
否 |
入参位提取 Key。 |
name |
| MappingType |
string |
否 |
后端参数类型。 |
java.lang.String |
| ServicePort |
integer |
否 |
服务端口。 |
443 |
| DomainId |
integer |
否 |
域名 ID。 |
20 |
| DestinationType |
string |
否 |
目标服务类型。
|
Multiple |
| DirectResponseJSON |
object |
否 |
Mock 响应配置。 |
|
| Code |
integer |
否 |
Mock 返回码。 |
403 |
| Body |
string |
否 |
Mock 返回值。 |
hello |
| GatewayUniqueId |
string |
是 |
网关唯一标识 ID。 |
gw-492af9b04bb4474cae9d645be8***** |
| DomainIdListJSON |
string |
是 |
域名列表。 |
[0,94] |
| RedirectJSON |
object |
否 |
重定向配置。 |
|
| Code |
integer |
否 |
返回码。 |
302 |
| Host |
string |
否 |
重定向主机名。 |
test.com |
| Path |
string |
否 |
重定向路径。 |
/test |
EnableWaf
deprecated
|
boolean |
否 |
已废弃,请使用 UpdateGatewayRouteWafStatus 更新路由 WAF 状态。 |
true |
| Fallback |
boolean |
否 |
是否开启 Fallback 服务。 |
true |
| FallbackServices |
array |
否 |
Fallback 服务。 |
|
|
object |
否 |
|||
| ServiceId |
integer |
否 |
服务 ID。 |
353 |
| Percent |
integer |
否 |
权重百分比。 |
80 |
| Version |
string |
否 |
服务版本。 |
v1 |
| Name |
string |
否 |
名称。 |
user |
| SourceType |
string |
否 |
来源类型。 |
MSE |
| Namespace |
string |
否 |
服务所在命名空间。 |
default |
| GroupName |
string |
否 |
服务分组名称。 |
test |
| AgreementType |
string |
否 |
协议类型。 |
DUBBO |
| ServicePort |
integer |
否 |
服务端口。 |
443 |
| RouteType |
string |
否 |
路由类型: Op:管控路由。 |
Op |
| Policies |
string |
否 |
路由策略 JSON 字符串。 |
{"CORS":"{\"allowMethods\":\"GET,POST,PUT,DELETE,HEAD,OPTIONS,PATCH\",\"allowHeaders\":\"*\",\"exposeHeaders\":\"*\",\"unitNum\":12,\"allowCredentials\":true,\"status\":\"off\",\"allowOrigins\":\"*\",\"timeUnit\":\"h\"}","Timeout":"{\"unitNum\":10,\"timeUnit\":\"s\",\"status\":\"off\"}","Retry":"{\"attempts\":2,\"retryOn\":[\"5xx\"],\"status\":\"off\"}","HTTPRewrite":"{\"pathType\":\"EQUAL\",\"path\":\"/o\",\"status\":\"off\"}","Waf":"{\"enabled\":false}","HeaderOp":"{\"status\":\"off\",\"headerOpItems\":[{\"directionType\":\"Request\",\"opType\":\"Add\",\"key\":\"kkk\",\"value\":\"ll\"}]}"} |
| Description |
string |
否 |
路由描述 |
a route for xxx |
| AcceptLanguage |
string |
否 |
返回信息的语言类型:
|
zh |
返回参数
|
名称 |
类型 |
描述 |
示例值 |
|
object |
数据结构。 |
||
| RequestId |
string |
请求 ID。 |
03A3E2F4-6804-5663-9D5D-2EC47A1***** |
| HttpStatusCode |
integer |
HTTP 状态码。 |
200 |
| Message |
string |
响应信息。 |
请求处理成功 |
| Code |
integer |
返回代码。 |
200 |
| Success |
boolean |
请求结果,取值如下:
|
true |
| Data |
integer |
创建的路由 ID。 |
555 |
| ErrorCode |
string |
错误码。
|
InvalidParameter |
示例
正常返回示例
JSON格式
{
"RequestId": "03A3E2F4-6804-5663-9D5D-2EC47A1*****",
"HttpStatusCode": 200,
"Message": "请求处理成功",
"Code": 200,
"Success": true,
"Data": 555,
"ErrorCode": "InvalidParameter"
}
错误码
|
HTTP status code |
错误码 |
错误信息 |
描述 |
|---|---|---|---|
| 400 | IllegalRequest | Invalid request:%s | 非法请求: %s |
| 400 | InvalidParameter | Parameter error:%s | 请求参数错误:%s |
| 500 | InternalError | Console error. Try again later:%s | 控制台错误.稍后重试:%s |
| 403 | NoPermission | You are not authorized to perform this operation:%s | 没有权限使用此接口:%s |
| 404 | NotFound | Not found:%s | 资源不存在:%s |
访问错误中心查看更多错误码。
变更历史
更多信息,参考变更详情。