Aws lambda Lambda Integration for API Gateway能否返回自定义对象?
我正在为API网关使用标准(非代理)Lambda集成 我的Lambda处理器如下所示:Aws lambda Lambda Integration for API Gateway能否返回自定义对象?,aws-lambda,aws-api-gateway,Aws Lambda,Aws Api Gateway,我正在为API网关使用标准(非代理)Lambda集成 我的Lambda处理器如下所示: public class MyAPI implements RequestHandler<CustomRequest, CustomResponse> { public CustomResponse handleRequest(CustomRequest request, Context lambdaContext) {\ .... ....
public class MyAPI implements RequestHandler<CustomRequest, CustomResponse> {
public CustomResponse handleRequest(CustomRequest request, Context lambdaContext) {\
....
....
//create an object of the custom response and return it
return CustomResponse.builder()....build();
}
}
但是我们不能为常规集成返回一个自定义对象并通过API网关将其序列化吗?您在API网关中设置了哪些响应映射?我尝试为集成响应添加映射。但是,当我返回对象时,来自端点本身的响应显示为空。似乎API网关无法进行序列化,即使我使用的对象显然是可序列化的。
{
statusCode: "...", // a valid HTTP status code
headers: {
custom-header: "..." // any API-specific custom header
},
body: "...", // a JSON string.
isBase64Encoded: true|false // for binary support
}