Cloud-native API Gateway supports adding policies and configuring plug-ins for APIs and API operations to improve their security, performance, and maintainability.
Policy configurations take effect immediately without needing to republish the API.
By default, API-level plug-in configurations are applied at the operation level.
While API-level policies cannot be deleted at the operation level, operation-level policies can overwrite API-level policies.
Procedure
Cloud-native API Gateway provides two ways to add API policies: outside instances and inside instances:
APIs outside instances
Log on to the Cloud-native API Gateway console. In the left-side navigation pane, select API, and select a region in the top menu bar.
Click the target API, and you can select the instance for which you want to add a policy from the dropdown list.

APIs inside instances
Log on to the Cloud-native API Gateway console. In the left-side navigation pane, select Instance, and select a region in the top menu bar.
On the Instance page, click the ID of the target gateway instance. In the left-side navigation pane, select API, and click the target API.
You can configure policies and plug-ins at the API level or operation level:
API level: Click the Policy Configuration tab to configure API-level policies and plug-ins for all operations, and click Enable Policy/Plug-in.
Operation level: In the operations list, click the target operation, click the Policy Configuration tab, and click Enable Policy/Plug-in.
In the Enable Policy/Plug-in panel, select a policy or plug-in to configure. For more information, see Policy configuration and Plug-in configuration.
Policy configuration
Throttling policy
Cloud-native API Gateway supports implementing throttling policies at the API and operation levels to effectively prevent external requests from exceeding the capacity of backend services and avoid cascading failures. The throttling feature helps you block some requests when the number of concurrent requests is large. This ensures the availability of backend services. You can precisely control the number of requests for each API and operation within a specified time period, ensuring it does not exceed the preset threshold.
Throttling policies include Concurrency Control, Traffic Shaping, and Circuit Breaking policies.
Concurrency control policy: The concurrency rule works by counting the total number of requests being processed by the gateway. When the metric reaches the set threshold, traffic is immediately blocked. You can configure the maximum number of concurrent requests that the backend service can process to protect the availability of backend services under high concurrency.
Traffic shaping policy: The traffic control rule works by monitoring the QPS metric of APIs and operations. When the metric reaches the set threshold, traffic is immediately blocked to prevent backend services from being overwhelmed by sudden traffic spikes, ensuring high availability.
Circuit breaking policy: The circuit breaking rule works by monitoring the response time or error rate of APIs and operations. When the specified threshold is reached, the dependency priority is immediately reduced. If circuit breaking is triggered, the system does not call the requests on the route in the specified period of time. This ensures high availability of backend services. After the specified period of time elapses, the system resumes the calls to the requests on the route.
Rewrite policy
You can configure a rewrite policy to flexibly change the paths and hostnames in requests before they are forwarded to their destination backend services. This meets the requirements for specific business environments and architectures. Rewrite policies allow you to precisely control the paths and hostnames of requests, ensuring that requests are correctly routed to the appropriate services or endpoints.
Header setting policy
You can configure a header setting policy to modify the headers in requests or responses before the requests are forwarded to destination backend services or before the responses of backend services are returned to clients.
Cross-origin resource sharing policy
CORS is an important security policy that allows web application servers to perform cross-origin access control. This helps implement secure data transfer. Cloud-native API Gateway supports configuring CORS policies at the API and operation levels. You can limit the domain names and request methods that are allowed to access resources based on your business requirements.
The CORS policy does not take effect for a mock service. You must configure an actual backend test service.
Traffic replication policy
The traffic replication policy allows you to replicate online application traffic to a specified service. This feature provides support for simulation tests and fault location on the system and helps you efficiently evaluate application performance and troubleshoot issues.
Timeout policy
Cloud-native API Gateway provides timeout settings at the API and operation levels. You can configure the maximum period of time for which a gateway waits for a response to a request for a specified API and operation. If a gateway does not receive a response from the backend service within the specified period of time, the gateway returns the 504 (Gateway Timeout) HTTP status code to the client.
Retry policy
Cloud-native API Gateway provides retry settings at the API and operation levels to automatically retry failed requests. You can configure a retry condition, such as failed connections, unavailable backend services, or a response with a specified HTTP status code.
Plug-in configuration
Click Add Plug-in tab.
In the Quick Navigation section, select the type of plug-in you want to install or search for a plug-in name, and click the plug-in card:
If the plug-in is not installed, click Install and Configure in the installation popup, configure the plug-in rules in the panel, and enable it.
If the plug-in is already installed, configure the plug-in rule and enable it.
Click OK to return to the API list, where you can see the mounting and enabling status of the plug-in.
