API Gateway - validating request parameters

喜夏-厌秋 提交于 2019-12-11 11:49:06

问题


So, I've heard about request validator in API gateway.

Is it possible to validate request if it has atleast 1 parameter/querystring?

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

Basically, what I want is that before a Lambda function is executed, this should consider these conditions first

  • SHOULD have a parameter

  • Either a name or an id should be in that parameter


回答1:


API Gateway can perform the basic validation. For the basic validation, API Gateway verifies either or both of the following conditions:

  • 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.

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.

Please read documentation here



来源:https://stackoverflow.com/questions/47467838/api-gateway-validating-request-parameters

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!