ALIYUN::MSE::GatewayRoute

ALIYUN::MSE::GatewayRoute类型用于添加网关路由。

语法

{
  "Type": "ALIYUN::MSE::GatewayRoute",
  "Properties": {
    "DomainIdList": List,
    "GatewayUniqueId": String,
    "Name": String,
    "Description": String,
    "DestinationType": String,
    "DomainId": Integer,
    "DirectResponseJSON": Map,
    "FallbackServices": List,
    "Fallback": Boolean,
    "GatewayId": Integer,
    "Policies": String,
    "Predicates": Map,
    "RouteType": String,
    "RouteOrder": Integer,
    "RedirectJSON": Map,
    "Services": List
  }
}

属性

属性名称

类型

必须

允许更新

描述

约束

DomainIdList

List

域名列表。

GatewayUniqueId

String

网关唯一标识 ID。

Name

String

路由名称。

Description

String

路由描述。

DestinationType

String

目标服务类型。

取值:

  • Single:单服务

  • Multiple:多服务

  • VersionOriented:标签路由

  • Mock:Mock

  • Redirect:重定向

DomainId

Integer

域名 ID。

DirectResponseJSON

Map

Mock响应配置。

更多信息,请参考DirectResponseJSON属性

FallbackServices

List

Fallback 服务。

更多信息,请参考FallbackServices属性

Fallback

Boolean

是否开启 Fallback 服务。

GatewayId

Integer

网关 ID。

Policies

String

路由策略 JSON 字符串。

Predicates

Map

匹配规则。

更多信息,请参考Predicates属性

RouteType

String

路由类型。

取值:

  • Op:管控路由。

RouteOrder

Integer

路由顺序。

数值越小优先级越高。

RedirectJSON

Map

重定向配置。

更多信息,请参考RedirectJSON属性

Services

List

服务列表。

路由指向为单服务、多服务、标签路由时填写。更多信息,请参考Services属性

Services语法

"Services": [
  {
    "AgreementType": String,
    "GroupName": String,
    "ServicePort": Integer,
    "Percent": Integer,
    "Version": String,
    "SourceType": String,
    "HttpDubboTranscoder": Map,
    "Namespace": String,
    "Name": String,
    "ServiceId": Integer
  }
]

Services属性

属性名称

类型

必须

允许更新

描述

约束

AgreementType

String

协议类型。

GroupName

String

服务分组名称。

HttpDubboTranscoder

Map

Dubbo 协议转换体。

更多信息,请参考HttpDubboTranscoder属性

Namespace

String

服务所在命名空间。

Name

String

服务名称。

Percent

Integer

当前服务/服务版本分流百分比。

只在使用多服务、标签路由时填写。

ServicePort

Integer

服务端口。

SourceType

String

来源类型。

ServiceId

Integer

服务 ID。

Version

String

服务版本。

只在使用标签路由时填写。

HttpDubboTranscoder语法

"HttpDubboTranscoder": {
  "DubboServiceName": String,
  "MothedMapList": List,
  "DubboServiceGroup": String,
  "DubboServiceVersion": String
}

HttpDubboTranscoder属性

属性名称

类型

必须

允许更新

描述

约束

DubboServiceName

String

Dubbo 服务名称。

DubboServiceGroup

String

服务组。

DubboServiceVersion

String

Dubbo服务版本。

MothedMapList

List

Dubbo 转发规则列表。

更多信息,请参考MothedMapList属性

MothedMapList语法

"MothedMapList": [
  {
    "DubboMothedName": String,
    "Mothedpath": String,
    "PassThroughList": List,
    "HttpMothed": String,
    "ParamMapsList": List,
    "PassThroughAllHeaders": String
  }
]

MothedMapList属性

属性名称

类型

必须

允许更新

描述

约束

DubboMothedName

String

Dubbo 方法名。

HttpMothed

String

HTTP 方法。

支持 HTTP 方法参数值。取值:

  • ALL_GET。

  • ALL_POST。

  • ALL_PUT。

  • ALL_DELETE。

  • ALL_PATCH。

Mothedpath

String

方法匹配路径。

PassThroughList

List

指定透传 Header 列表。

ParamMapsList

List

参数映射列表。

更多信息,请参考ParamMapsList属性

PassThroughAllHeaders

String

Header 透传类型。

透传类型枚举值。

  • 透传所有:PASS_ALL。

  • 不透传:PASS_NOT。

  • 指定参数:PASS_ASSIGN。

ParamMapsList语法

"ParamMapsList": [
  {
    "MappingType": String,
    "ExtractKeySpec": String,
    "ExtractKey": String
  }
]

ParamMapsList属性

属性名称

类型

必须

允许更新

描述

约束

ExtractKeySpec

String

入参位置。

取值:

  • ALL_QUERY_PARAMETER

  • ALL_HEADER

  • ALL_PATH

  • ALL_BODY

ExtractKey

String

入参位提取 Key。

MappingType

String

后端参数类型。

RedirectJSON语法

"RedirectJSON": {
  "Path": String,
  "Host": String,
  "Code": Integer
}

RedirectJSON属性

属性名称

类型

必须

允许更新

描述

约束

Code

Integer

返回码。

Host

String

重定向主机名。

Path

String

重定向路径。

DirectResponseJSON语法

"DirectResponseJSON": {
  "Body": String,
  "Code": Integer
}

DirectResponseJSON属性

属性名称

类型

必须

允许更新

描述

约束

Body

String

Mock 返回值。

Code

Integer

Mock 返回码。

FallbackServices语法

"FallbackServices": [
  {
    "AgreementType": String,
    "GroupName": String,
    "ServicePort": Integer,
    "Percent": Integer,
    "Version": String,
    "SourceType": String,
    "Namespace": String,
    "Name": String,
    "ServiceId": Integer
  }
]

FallbackServices属性

属性名称

类型

必须

允许更新

描述

约束

AgreementType

String

协议类型。

GroupName

String

服务分组名称。

Namespace

String

服务所在的命名空间。

Name

String

名称。

Percent

Integer

当前服务/服务版本分流百分比。

只在使用多服务、标签路由时填写。

ServicePort

Integer

服务端口。

SourceType

String

来源类型。

ServiceId

Integer

服务 ID。

Version

String

服务版本。

Predicates语法

"Predicates": {
  "HeaderPredicates": List,
  "MethodPredicates": List,
  "QueryPredicates": List,
  "PathPredicates": Map
}

Predicates属性

属性名称

类型

必须

允许更新

描述

约束

HeaderPredicates

List

请求头匹配。

更多信息,请参考HeaderPredicates属性

MethodPredicates

List

方法匹配。

{'Length': {'Max': 20}}

PathPredicates

Map

路由匹配。

更多信息,请参考PathPredicates属性

QueryPredicates

List

URL 参数匹配。

更多信息,请参考QueryPredicates属性

HeaderPredicates语法

"HeaderPredicates": [
  {
    "Type": String,
    "Value": String,
    "Key": String
  }
]

HeaderPredicates属性

属性名称

类型

必须

允许更新

描述

约束

Key

String

请求头 Key。

Type

String

匹配类型。

Value

String

对应的 Value。

QueryPredicates语法

"QueryPredicates": [
  {
    "Type": String,
    "Value": String,
    "Key": String
  }
]

QueryPredicates属性

属性名称

类型

必须

允许更新

描述

约束

Key

String

参数名。

Type

String

匹配类型。

Value

String

匹配值。

PathPredicates语法

"PathPredicates": {
  "Path": String,
  "Type": String,
  "IgnoreCase": Boolean
}

PathPredicates属性

属性名称

类型

必须

允许更新

描述

约束

IgnoreCase

Boolean

None

Whether to ignore case when matching paths.

Path

String

路径。

Type

String

路由匹配。

取值:

  • PRE:前缀。

  • EQUAL:精确。

  • ERGULAR:正则。

返回值

Fn::GetAtt

RouteId:路由ID。

示例

ROSTemplateFormatVersion: '2015-09-01'
Parameters:
  Name:
    Required: true
    Type: String
    Description:
      en: The name of the route.
  DomainIdList:
    AssociationProperty: List[Parameter]
    AssociationPropertyMetadata:
      Parameter:
        Default: Null
        Required: false
        Type: String
        Description:
          en: The domain ID in JSON format.
    Required: true
    Type: Json
    Description:
      en: The list of domain IDs in JSON format.
  GatewayUniqueId:
    Required: true
    Type: String
    Description:
      en: The unique ID of the gateway.
Resources:
  GatewayRoute:
    Type: ALIYUN::MSE::GatewayRoute
    Properties:
      Name:
        Ref: Name
      DomainIdList:
        Ref: DomainIdList
      GatewayUniqueId:
        Ref: GatewayUniqueId
Outputs:
  RouteId:
    Description: The ID of the route.
    Value:
      Fn::GetAtt:
        - GatewayRoute
        - RouteId

                        
{
  "ROSTemplateFormatVersion": "2015-09-01",
  "Parameters": {
    "Name": {
      "Required": true,
      "Type": "String",
      "Description": {
        "en": "The name of the route."
      }
    },
    "DomainIdList": {
      "AssociationProperty": "List[Parameter]",
      "AssociationPropertyMetadata": {
        "Parameter": {
          "Default": null,
          "Required": false,
          "Type": "String",
          "Description": {
            "en": "The domain ID in JSON format."
          }
        }
      },
      "Required": true,
      "Type": "Json",
      "Description": {
        "en": "The list of domain IDs in JSON format."
      }
    },
    "GatewayUniqueId": {
      "Required": true,
      "Type": "String",
      "Description": {
        "en": "The unique ID of the gateway."
      }
    }
  },
  "Resources": {
    "GatewayRoute": {
      "Type": "ALIYUN::MSE::GatewayRoute",
      "Properties": {
        "Name": {
          "Ref": "Name"
        },
        "DomainIdList": {
          "Ref": "DomainIdList"
        },
        "GatewayUniqueId": {
          "Ref": "GatewayUniqueId"
        }
      }
    }
  },
  "Outputs": {
    "RouteId": {
      "Description": "The ID of the route.",
      "Value": {
        "Fn::GetAtt": [
          "GatewayRoute",
          "RouteId"
        ]
      }
    }
  }
}