Docs
uapigateway
Operation Guide
Open API
Strategy Management

Strategy Description

  • A strategy is created according to the corresponding strategy template for API restrictions and open conditions. The content of the strategy now supports both YAML and JSON text formats. Here is an example of CORS cross-domain strategy.
  • Once the strategy is generated, you can bind it to the API in the corresponding environment. You can view the corresponding API information and the publication status of the API in the list of binded APIs in the strategy details. Once the strategy is bound, it takes effect immediately.

YAML Example:

---
allowOrigins: {{consoleURLwithoutHttp}}	# This is the ORIGIN allowed, separated by commas. "*" Represents all domains
allowMethods: GET,POST,PUT				# Here are the methods allowed, separated by commas
allowHeaders: X-Gw-Request-Id			# Here are the request headers allowed, separated by commas
exposeHeaders: X-RC1,X-RC2			# Headers that are allowed to be exposed to the XMLHttpRequest object, separated by commas
allowCredentials: true					# Whether to allow cookies or not
maxAge: 172800

JSON Example:

{
    "allowOrigins" : "console.ucloud-global.com",  //This is the ORIGIN allowed, separated by commas. "*" Represents all domains
    "allowMethods" : "GET,POST,PUT",   //Here are the methods allowed, separated by commas
    "allowHeaders" : "X-Gw-Request-Id",  //Here are the request headers allowed, separated by commas
    "exposeHeaders" : "exposeHeaders",  //Headers that are allowed to be exposed to the XMLHttpRequest object, separated by commas
    "allowCredentials" : true,          //Whether to allow cookies or not
    "maxAge" : 172800                   //Pre-inspection caching time, in seconds
}

Create Strategy

In order to accurately identify, strategies under the same project should not have the same name. For different types of strategies, the configuration may be different. Please refer to the default configuration and code comments for the specific response.

API Binding Strategy

A strategy can be bound to an API in a given environment. If the API is already running in the environment, it takes effect immediately without publishing. If your strategy is in use, please modify it carefully. When binding the API, first filter according to the API group, then select the API to be bound and the environment to be bound, and click confirm.