[英]How can I restrict specific parameters in payload from API Gateway to AWS Lambda?
I have to send a request body (payload) from API Gateway to AWS Lambda. In that payload, I only need to send:我必须从 API 网关向 AWS Lambda 发送请求正文(有效负载)。在该有效负载中,我只需要发送:
{
"path":"aaa"
"action":"xyz"
}
If someone passes any other parameter in the payload, it should not accept the payload and show an error message.如果有人在有效载荷中传递任何其他参数,它不应该接受有效载荷并显示错误消息。 Could somebody please help me with the logic?有人可以帮我解决逻辑问题吗?
For AWS API Gateway you can implement request validation using an OpenAPI template.对于 AWS API 网关,您可以使用 OpenAPI 模板实施请求验证。 The extension should work for both Rest and Http APIs.该扩展应该适用于 Rest 和 Http API。
For even more flexibility you could implement a Lambda authorizer which evaluates the body, but of course this leads to more costs as well:为了获得更大的灵活性,您可以实施一个 Lambda 授权方来评估主体,但这当然也会导致更多成本:
https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-lambda-authorizer.html https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-lambda-authorizer.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.