Parameter | Required | Description |
Function | Yes | Select the namespace, name, and version of the function that is used to modify the request body. |
Backend timeout | Yes | Set the backend timeout that API Gateway forwards the request to the function that is used to modify the request body. The maximum time limit is 30 minutes. When no response is returned before the timeout after API Gateway calls the function, API Gateway will end the call and return an error message. |
Custom content | Yes | Set the request content sent by API Gateway to the function used to modify the request body. You can select Header, Body, and Query. The request content not selected will not be modified and will be forwarded to the service backend as is. |
Base64 Encoding | Yes | Specify whether to forward the request content to the function after applying Base64 encoding. Generally, it is applicable to binary content. |
Parameter | Required | Description |
Request method | Yes | Request method of the custom request body function, which can be GET, POST, PUT, DELETE, HEAD, and ANY. |
Public network service | Yes | Access address of the request body service, which can be an HTTP or HTTPS address. |
Path match mode | Yes | It can be backend path or full path match. Backend path match: The configured path is used to request the service. Full path match: The overlapping part is used to request the service. For example, if the configured API path is `/a/` and the request path is `/a/b`, then the path transferred to the service will be `/b` after full path match is enabled. |
Parameter | Required | Description |
VPC | Yes | Select the VPC of the custom request rewriting service. |
Request method | Yes | Request method of the custom request rewriting service, which can be GET, POST, PUT, DELETE, HEAD, and ANY. |
Backend address | Yes | Access address of the custom request body service, which can be an HTTP or HTTPS address. |
{"replace_headers":{"header1":"header1-value","header2":"header2-value"},"remove_headers":["header3","header4"],"replace_body":"hello","replace_querys":{"query1":"query1-value","query2":"query2-value"},"remove_querys":["query3","query4"]}
package com.example.demo;import com.google.gson.JsonArray;import com.google.gson.JsonObject;import com.qcloud.services.scf.runtime.events.APIGatewayProxyRequestEvent;public class Demo {public String mainHandler(APIGatewayProxyRequestEvent request) {System.out.println("helloworld");System.out.println(request.getHttpMethod());JsonObject resp = new JsonObject();headerHandler(request, resp);headerQuery(request, resp);headerBody(request, resp);return resp.toString();}private void headerHandler(APIGatewayProxyRequestEvent request, JsonObject resp) {JsonObject replace_headers = new JsonObject();JsonArray remove_headers = new JsonArray();// Sample: Replace or add `header1` and `header2`replace_headers.addProperty("header1", "header1-value");replace_headers.addProperty("header2", "header2-value");// Sample: Delete `query3`remove_headers.add("header3");resp.add("replace_headers", replace_headers);resp.add("remove_headers", remove_headers);}private void headerQuery(APIGatewayProxyRequestEvent request, JsonObject resp) {JsonObject replace_querys = new JsonObject();JsonArray remove_querys = new JsonArray();// Sample: Replace or add `query1` and `query2`replace_querys.addProperty("query1", "query1-value");replace_querys.addProperty("query2", "query2-value");// Sample: Delete `query3`remove_querys.add("query3");resp.add("replace_querys", replace_querys);resp.add("remove_querys", remove_querys);}private void headerBody(APIGatewayProxyRequestEvent request, JsonObject resp) {resp.addProperty("replace_body", "{'name':'Yagr'}");}}
{"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 forward the request content to the SCF after applying Base64 encoding"is_send_req_body":true, // Whether to send the request Body content to the SCF"is_send_req_headers":true, // Whether to send the request Header content to the SCF"is_send_req_querys":true, // Whether to send the request Query content to the SCF"user_id":1253970226 // appid}
Was this page helpful?