Function Compute can use API Gateway as an event source. When API Gateway receives a request for an API operation that uses Function Compute as its backend service, API Gateway triggers the execution of the corresponding function in Function Compute. Then, Function Compute returns the execution result to API Gateway.


API Gateway triggers are similar to HTTP triggers, and can be used to build web applications. Compared with HTTP triggers, API Gateway triggers allow you to perform advanced operations such as setting the IP whitelist or blacklist.

How it works

After API Gateway receives a request for an API operation with Function Compute as the backend service, API Gateway converts the request parameters to key-value pairs in the map format and sends the request to Function Compute. Function Compute handles the request and returns a response in a specific output format to API Gateway. The response includes information such as the status code, header, and body, as shown in the following figure. API Gateway maps the information in the response that is returned by Function Compute to the status code, header, and body of an API response, and returns the API response to the client.