路由管理
1.查询路由
接口功能介绍
无
接口约束
无
URI
GET /cgw/v1/route/one
Accept: application/json
路径参数
Query参数
参数 | 是否必填 | 参数类型 | 说明 | 示例 | 下级对象 |
---|---|---|---|---|---|
instId | 是 | String | 实例Id | 7a2828074ef6e32e041a2ef124b19e63 | |
id | 是 | String | 路由资源Id |
请求参数
请求头header参数
参数 | 是否必填 | 参数类型 | 说明 | 示例 | 下级对象 |
---|---|---|---|---|---|
regionId | 是 | String | 资源池编码 | 7a2828074ef6e32e041a2ef124b19e63 |
请求体body参数
响应参数
返回参数说明
参数 | 参数类型 | 说明 | 示例 | 下级对象 |
---|---|---|---|---|
statusCode | Integer | 接口状态码 | 2000 | |
code | String | 错误码,异常时非空 | CGW_1001 | |
returnObj | Object | 返回数据 | RouteVO | |
message | String | 异常描述 | success |
表 RouteVO
参数 | 参数类型 | 说明 | 示例 | 下级对象 |
---|---|---|---|---|
corsVO | Object | 跨域策略 | CorsVO | |
countLimit | Object | 限流策略 | CountLimit | |
createTime | String | 创建时间 | ||
description | String | 路由描述 | ||
destinationType | String | 目标服务类型, Single: 单服务;Multiple:多服务;VersionOriented:标签路由 | single | |
headerRewriteVO | Object | header设置策略 | HeaderRewriteVO | |
hosts | Array of Strings | 域名列表 | [“test.com”] | |
httpRewrite | Object | http重写策略 | HttpRewrite | |
id | String | ID | 7a2828074ef6e32e041a2ef124b19e63 | |
uri | String | 请求路径 | /app/a | |
uris | Array of Strings | 请求路径列表 | [“/app/a”, “/app/b”] | |
methods | Array of Strings | HTTP方法 | [“GET”, “PUT”] | |
mockResponse | Object | Mock路由响应体 | MockResponseVO | |
name | String | 名称 | test | |
predicates | String | 路由规则(String) | ||
priority | Integer | 优先级 | 100 | |
proxyCookieVO | Object | proxy-cookie策略 | ProxyCookieVO | |
queryRewriteVO | Object | query参数设置策略 | QueryRewriteVO | |
redirect | Object | 重定向 | RedirectVO | |
routeAuthType | String | 认证方式 | ||
routeAuthTypeName | String | 认证方式名称 | ||
routePredicate | Object | 路由规则 | RoutePredicate | |
routeTagNormalize | Object | 路由参数规整化 | RouteTagNormalize | |
routeTagNormalizedFlag | Boolean | 是否启用路由参数规整化处理 | false | |
status | Integer | 状态,1:已发布;0:未发布 | 0 | |
type | String | 路由配置类型:control、ingress | ||
typeDesc | String | 路由配置类型描述:管控、Ingress | ||
updateTime | Long | 更新时间 | 2023-10-01 12:12:12 | |
upstreamList | Array of Objects | 目标服务 | DestinationUpstreamVO |
表 CorsVO
参数 | 参数类型 | 说明 | 示例 | 下级对象 |
---|---|---|---|---|
allowCredential | Boolean | 允许携带凭证,使用 * 来表示所有 Origin 均允许通过,默认为* |
||
allowHeaders | String | 允许的请求头部,回车分隔;使用 * 来表示所有 header 均允许通过,默认为* |
* | |
allowMethods | String | 允许的请求方法,逗号分隔;使用 * 来表示所有 method均允许通过,默认为* |
GET,POST | |
allowOrigins | String | 允许的访问来源,回车分隔;使用 * 来表示所有 Origin 均允许通过,默认为* |
* | |
enable | Boolean | 开启状态 true:开启,false:关闭,默认为false | false | |
exposeHeaders | String | 允许的响应头部,回车分隔;使用 * 来表示所有 header 均允许通过,默认为* |
* | |
maxAge | Integer | 预检的过期时间 | 5 | |
timeType | String | 预检的过期时间单位, d、h、m、s | s |
表 CountLimit
参数 | 参数类型 | 说明 | 示例 | 下级对象 |
---|---|---|---|---|
count | Integer | 限制请求次数 limit | 10 | |
enable | Boolean | 开启状态 true:开启,false:关闭 | false | |
timeUnit | String | 时间窗口单位 TimeUnit,天:d,时:h,分:m,秒:s | s | |
time_window | Integer | 时间窗口 UnitNum | 60 |
表 HeaderRewriteVO
参数 | 参数类型 | 说明 | 示例 | 下级对象 |
---|---|---|---|---|
enable | Boolean | 开启状态 true:开启,false:关闭 | false | |
headerParameters | Array of Objects | 规则列表 | HeaderParameter |
表 HeaderParameter
参数 | 参数类型 | 说明 | 示例 | 下级对象 |
---|---|---|---|---|
headerKey | String | header key头部名 | name | |
headerType | String | header类型, 请求(request)、响应(response) | request | |
headerValue | String | header value头部值, String 或者 number | tom | |
optionType | String | 操作类型,新增(add)、修改(update)、删除(delete) | add |
表 HttpRewrite
参数 | 参数类型 | 说明 | 示例 | 下级对象 |
---|---|---|---|---|
enable | Boolean | 是否启用 true:启用,false:停用 | false | |
originHost | String | 原主机域,从路由配置host中读取 | test.com | |
originPath | String | 原路径,从路由配置uri中读取 | /app/a | |
originType | String | 原类型,从路由配置中读取 | ||
pathMatchType | String | 重写路径匹配类型, 前缀匹配:PRE, 精确匹配:EQUAL, 正则匹配:REGEX | EQUAL | |
prefixMatchPattern | String | 前缀匹配类型时待匹配的路径 | ||
regexMatchPattern | String | 正则匹配时提供的正则表达式 | ||
rewriteHost | String | 重写主机域 | hello.com | |
rewritePath | String | 重写路径 | /app/c |
表 MockResponseVO
参数 | 参数类型 | 说明 | 示例 | 下级对象 |
---|---|---|---|---|
code | Integer | 自定义响应code | 302 | |
responseJson | String | 自定义响应信息 | {“name”: “tom”} |
表 ProxyCookieVO
参数 | 参数类型 | 说明 | 示例 | 下级对象 |
---|---|---|---|---|
domain | Object | proxy_cookie_domain配置信息 | ProxyCookieInfo | |
enable | Boolean | 开启状态 true:开启,false:关闭 | false | |
path | Object | proxy_cookie_path配置信息 | ProxyCookieInfo |
表 ProxyCookieInfo
参数 | 参数类型 | 说明 | 示例 | 下级对象 |
---|---|---|---|---|
regex | String | 匹配规则,use为true时,不可为空 | /test | |
replacement | String | 替换值,use为true时,不可为空 | /test/app | |
use | Boolean | 是否启用属性,true为启用,默认为false | true |
表 QueryRewriteVO
参数 | 参数类型 | 说明 | 示例 | 下级对象 |
---|---|---|---|---|
domain | Object | proxy_cookie_domain配置信息 | ProxyCookieInfo | |
enable | Boolean | 开启状态 true:开启,false:关闭 | false | |
path | Object | proxy_cookie_path配置信息 | ProxyCookieInfo |
表 RedirectVO
参数 | 参数类型 | 说明 | 示例 | 下级对象 |
---|---|---|---|---|
code | Integer | 自定义code | 329 | |
uri | String | 自定义重定向路径 | /redirect |
表 routePredicate
参数 | 参数类型 | 说明 | 示例 | 下级对象 |
---|---|---|---|---|
cookiePredicates | Array of Objects | cookie匹配参数 | Predicate | |
headerPredicates | Array of Objects | http匹配参数 | Predicate | |
queryPredicates | Array of Objects | query匹配参数 | Predicate |
表 Predicate
参数 | 参数类型 | 说明 | 示例 | 下级对象 |
---|---|---|---|---|
key | String | KEY | id | |
type | String | 匹配类型,==:等于,~~=:不等于,>:大于,>=:大于等于,<:小于,<=:小于等于,~~:正则匹配,~~*:正则匹配(不区分大小写),IN:存在于,HAS:包含,!:非 | == | |
value | String | 值 | 1 |
表 RouteTagNormalizeDTO
参数 | 参数类型 | 说明 | 示例 | 下级对象 |
---|---|---|---|---|
hashFlag | Boolean | 是否进行hash | false | |
moduloOperationValue | Integer | 取模数值 | 100 | |
paramLocation | String | 参数位置,支持header, query, cookie | header | |
paramName | String | 参数名称 | id | |
tagExactValues | Array of Integer | 精确型标记取值,传入匹配值 | exact | |
tagRangeValueList | Array of Objects | 范围型标记取值,传入最大和最小值。支持传入多组范围,多组范围之间是或关系 | TagRangeDTO | |
tagType | String | 标记类型。范围:range,0-3000;精确:exact: 0,1,2 | exact |
表 TagRangeDTO
参数 | 参数类型 | 说明 | 示例 | 下级对象 |
---|---|---|---|---|
includeMax | Boolean | 是否包含最大值 | false | |
includeMax | Boolean | 是否包含最小值 | false | |
max | Integer | 范围上限 | 1000 | |
min | Integer | 范围下限 | 1 |
表 HttpRewrite
参数 | 参数类型 | 说明 | 示例 | 下级对象 |
---|---|---|---|---|
enable | Boolean | 是否启用 true:启用,false:停用 | false | |
originHost | String | 原主机域,从路由配置host中读取 | test.com | |
originPath | String | 原路径,从路由配置uri中读取 | /app/a | |
originType | String | 原类型,从路由配置中读取 | ||
pathMatchType | String | 重写路径匹配类型, 前缀匹配:PRE, 精确匹配:EQUAL, 正则匹配:REGEX | EQUAL | |
prefixMatchPattern | String | 前缀匹配类型时待匹配的路径 | ||
regexMatchPattern | String | 正则匹配时提供的正则表达式 | ||
rewriteHost | String | 重写主机域 | hello.com | |
rewritePath | String | 重写路径 | /app/c |
表 DestinationUpstreamVO
参数 | 参数类型 | 说明 | 示例 | 下级对象 |
---|---|---|---|---|
groupName | String | 分组名 | DEFAULT | |
namespace | String | 命名空间 | prod | |
sourceType | String | 来源类型 | nacos | |
upstreamId | String | 服务id | 123456789 | |
upstreamName | String | 服务名 | svc-test | |
versionId | String | |||
versionName | String | |||
versions | Array of Objects | UpstreamVersionVO |
表 UpstreamVersionVO
参数 | 参数类型 | 说明 | 示例 | 下级对象 |
---|---|---|---|---|
id | String | 服务版本内部id | 34526187329 | |
instNum | Integer | 实例数 | 1 | |
instNumPercent | String | 实例比例% | 100% | |
labelName | String | 标签名原始值。用于传参,和tips展示 | name | |
labelNameVO | String | 标签名别名,用于web展示 | ||
labelValue | String | 标签值原始值。用于传参,和tips展示 | ||
labelValueVO | String | 标签值别名,用于web展示 | ||
upstreamId | String | 服务内部id | 78965423445 | |
versionName | String | 服务版本名称 | version-test |
请求示例
请求url
https://127.0.0.1:8080/cgw/v1/route/one?instId=String
请求头header
{
"regionId": "1234567890"
}
请求体body
响应示例
{
"statusCode": 2000,
"message": "success",
"returnObj": {
"id": "00000000000000000020",
"name": "test",
"status": 1,
"uri": "/test",
"destinationType": "mock",
"methods": [
"GET",
"PUT",
"POST",
"DELETE",
"PATCH",
"HEAD",
"OPTIONS",
"CONNECT",
"TRACE"
],
"priority": 0,
"updateTime": "2023-05-10 20:40:06",
"createTime": "2023-05-05 19:54:21",
"routePredicate": {
"headerPredicates": [],
"queryPredicates": []
},
"predicates": "{\"headerPredicates\":[],\"queryPredicates\":[]}",
"httpRewrite": {
"originPath": "/test",
"rewritePath": "/def",
"prefixMatchPattern": "/abc",
"pathMatchType": "PRE",
"enable": false
},
"countLimit": {
"time_window": 10,
"timeUnit": "s",
"count": 60,
"enable": false
},
"headerRewriteVO": {
"headerParameters": [
{
"headerType": "request",
"optionType": "add",
"headerKey": "num",
"headerValue": "10"
}
],
"enable": false
},
"corsVO": {
"allowOrigins": "*",
"allowMethods": "*",
"allowHeaders": "*",
"exposeHeaders": "*",
"maxAge": 5,
"timeType": "s",
"allowCredential": false,
"enable": false
},
"proxyCookieVO": {
"path": {
"use": true,
"regex": "/foo/",
"replacement": "/bar"
},
"domain": {
"use": false
},
"enable": false
},
"mockResponse": {
"statusCode": 2000,
"responseJson": "ok"
}
}
}
状态码
请参考 状态码说明。
错误码
请参考 错误码说明。