[英]How can I get common response format for Lambda API?
I am using Node.js for AWS Lambda + API Gateway APIs. 我正在将Node.js用于AWS Lambda + API网关API。
I have multiple Lambda functions and each giving different response formats as it integrated multiple third party SDKs like Stripe/DynamoDB and all. 我有多个Lambda函数,并且每个函数都提供不同的响应格式,因为它集成了诸如Stripe / DynamoDB之类的多个第三方SDK。
Is there any way to get common response for all the functions like below? 有什么办法可以使所有类似下面的功能得到共同的响应?
{
"success" : true,
"data" : { RESPONSEFROMLAMBDA },
"messages" : null,
"code" : 200,
"description" : "OK"
}
The third-party services your Lambda functions are using shouldn't have any bearing on the response format. Lambda函数使用的第三方服务与响应格式没有任何关系。 You just need to update all the API Gateway endpoints to use a mapping template with this format.
您只需要更新所有API网关端点即可使用具有这种格式的映射模板。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.