API网关-验证请求参数 [英] API Gateway - validating request parameters

查看:524
本文介绍了API网关-验证请求参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,我听说过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.

适用的请求有效负载遵循已配置的JSON-Schema请求

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆