The response body sent to the Client by API Gateway contains many fields. If you want to modify the content of the response body, you can do so via custom response body plugin.
The custom response body plugin is implemented based on SCF and applies during the response process as follows:
The service backend will send the response body to the API Gateway after processing the request packet. The API Gateway will forward the response content to the specified SCF instead of sending it to the Client after receiving it. SCF will send the modified content of response body to the API Gateway after modifying it. Then, the API Gateway will forward the modified response body to service backend.
Note:You need to write the SCF that is used to modify the response body. For more information, see Template of Custom Response Body SCF.
Parameter | Type | Description |
---|---|---|
Select an SCF | Required | You need to select the namespace, name and version of the SCF that is used to modify the response body. |
Backend timeout | Required | This sets the backend timeout that the API Gateway forwards the response to the SCF that is used to modify the response body. The maximum time limit is 30 minutes. When no response is returned before the timeout after the API Gateway calls the SCF, the API Gateway will end the call and return an error message. |
Custom content | Required | It sets the response content sent to the SCF by the API Gateway. You can select Header, Body and response status code. The response content not selected will not be modified and will be returned to the Client as is. |
Base64 encoding | Required | It specifies whether to Base64-encode the response content to be forwarded by the service backend to the SCF. Generally, it is applicable to binary content. |
{
"endpoint_timeout":15, // Backend timeout period in seconds. Value range: 0–60
"func_name":"test_name", // Custom SCF name
"func_namespace":"test_namespace", // Custom SCF namespace
"func_qualifier":"$LATEST", // Custom SCF version
"is_base64_encoded":true, // Whether to Base64-encode the response content to be forwarded by the service backend to the SCF
"is_custom_status":true, // Whether to send the response status code content to the SCF
"is_custom_headers":true, // Whether to send the response Header content to the SCF
"is_custom_body":true, // Whether to send the response Body content to the SCF
"user_id":1253970226 // appid
}
Was this page helpful?