Parameter | Required | Description |
Policy name | Yes | Current policy name, which can contain up to 50 characters and must be unique in the same plugin. |
Weight | Yes | Priority for policy match. You can enter a positive integer between 0 and 100. If it is not set, it will be 0 by default. The greater the weight, the higher the match priority. For policies with the same weight, the later the creation time, the higher the priority. |
Trigger condition | Yes | Conditional expression that judges whether the client request meets the condition. For more information, see the relevant description below. |
Backend type | Yes | Public network URL/IP, VPC resources, SCF, Mock, and TSF are supported. |
Backend configuration | Yes | Backend to which the client request will be forwarded if the request meets the condition. Enter the backend configuration in YAML format. |
Header
, Path
, and Query
parameters are supported.a
parameter in the Header
location is configured in the frontend configuration, you can use header.a
to represent this parameter in the plugin.Path
parameter has no parameter name and is therefore represented by a path; for example, path='/test'
indicates that the condition is met if the request path is /test
.Path
parameter must start with /
, such as '/test'
.sysparam
to reference system parameters of the current request without defining them in the API; however, if you define a parameter with the same name in the API, the value in the API will be overwritten by the value of the custom parameter. We recommend you enter the parameter value in lower camel case and make it case-insensitive. The following system parameters can be used in the routing plugin:UserAgent
field uploaded by the client.header.a
parameter, the parameter location header
is case-insensitive, while the parameter name a
is case-sensitive.Constant Type | Description | Example |
STRING | String | Double and single quotation marks are supported, such as "Hello" and 'hello' |
INTEGER | Integer | 1001, -1 |
NUMBER | Floating point | 0.1, 100.0 |
BOOLEAN | Boolean | true, false |
and
and or
to concatenate different expressions.()
to specify the priority for condition match.Random()
can generate a floating point parameter where the value is in NUMBER
data type and ranges from 0 to 1 for random judgment.param.unknown = 1
is used in the expression, false
will be returned.regex()
to match the parameter value, for example, regex(query.name,"colou?r")
. You need to enclose the string in the regular expression with single or double quotation marks.exists()
function to specify whether a parameter exists, for example, exists(header.Accept)
.==
and =
can be used to judge the "equal to" relationship.UserName
in the custom Header
parameter is Admin
, and the source IP is 47.47.74.77: header.UserName = 'Admin' and sysparam.clientIp = '47.47.74.77'Header
) of the current request is 1001
, 1098
, or 2011
, and the request uses the HTTPS protocol: sysparam.httpScheme = 'https' and (header.id = 1001 or header.id = 1098 or header.id = 2011)ServiceConfig:Method: GETPath: /testUrl: 'http://test.com'ServiceType: HTTP
ServiceConfig:Method: GETPath: /testUrl: 'http://test.com'UniqVpcId: vpc-xxxxxProduct: clbServiceType: HTTP
ServiceScfFunctionName: scftestServiceScfFunctionNamespace: mynamespaceServiceScfFunctionQualifier: $DEFAULTServiceScfFunctionType: EVENTServiceScfIsIntegratedResponse: falseServiceType: SCF
ServiceMockReturnMessage: hello mock from strategyServiceType: MOCK
X-MicroService-Name: consumer-demoX-NameSpace-Code: mytsfMicroServices:- ClusterId: cls-xxxxxxMicroServiceName: tsf-demoNamespaceId: namespace-xxxxxxServiceConfig:Method: ANYPath: /xxxxUrl: ''ServiceTsfHealthCheckConf:IsHealthCheck: trueServiceTsfLoadBalanceConf:IsLoadBalance: trueMethod: RoundRobinRuleSessionStickRequired: falseServiceType: TSF
[{"strategy_name":"route-to-http", // Policy name, which can contain up to 50 letters, digits, and special symbols (%~_\\-.{}?&=) and must be unique in the same plugin"strategy_weight":2, // Priority for policy match. You can enter a positive integer between 0 and 100. If it is not set, it will be 0 by default"condition":"query.age<30 and query.need_verify=false or query.level>3", // Conditional expression"backend_type":"HTTP", // Type of the backend for routing and forwarding. Valid values: MOCK, HTTP, SCF, VPC, UPSTREAM, TSF"backend_config":{ // Backend configuration"ServiceConfig":{"Method":"GET","Path":"/v1/bpi/currentprice.json","Url":"https://api.coindesk.com"},"ServiceType":"HTTP"}}]
Was this page helpful?