API网关-验证请求参数 [英] API Gateway - validating request parameters
问题描述
因此,我听说过API网关中的请求验证器.
So, I've heard about request validator in API gateway.
是否可以验证请求中是否包含至少1个参数/查询字符串?
Is it possible to validate request if it has atleast 1 parameter/querystring?
示例:名称或id应该在查询字符串中
Example: Either name or id should be in the query string
https://something.domain.com/dev/employee?name=myname https://something.domain.com/dev/employee?id=myid
基本上,我想要的是在执行Lambda函数之前,应该首先考虑这些条件
Basically, what I want is that before a Lambda function is executed, this should consider these conditions first
-
应该有一个参数
SHOULD have a parameter
该参数中应包含名称或ID
Either a name or an id should be in that parameter
推荐答案
API网关可以执行基本验证.对于基本验证,API Gateway验证以下两个条件中的一个或两个:
API Gateway can perform the basic validation. For the basic validation, API Gateway verifies either or both of the following conditions:
-
URI中包含必需的请求参数,查询字符串和传入请求的标头,这些参数是非空白的.
The required request parameters in the URI, query string, and headers of an incoming request are included and non-blank.
The applicable request payload adheres to the configured JSON-Schema request model of the method.
要启用基本验证,请在请求验证器,将验证器添加到API的请求验证程序的映射,然后将验证程序分配给各个API方法.
To enable basic validation, you specify validation rules in a request validator, add the validator to the API's map of request validators, and assign the validator to individual API methods.
请在此处
这篇关于API网关-验证请求参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!