具有代理集成的 AWS HTTP API 网关 - 型号

AWS HTTP API gateway with proxy integration - Model

我在 documentation 上看到他们如何解释 REST API 模型架构,但不是 HTTP API。这是因为 HTTP API 不需要模型吗?

例如我在 DynamoDB 中有这个数据:

通常在 REST API 中,人们会执行作为模型一部分的用户输入验证(如果我是正确的话),我在 HTTP API 中看不到该选项。有人可以向我解释我是如何为 HTTP API 构建(或者如果需要的话)这个模型的吗?例如,如果用户转到 /todos/{id} 怎么办?

这个模型概念是转移到 lambda 或其他地方还是仍然存在于网关中?

谢谢

HTTP API is more recent addition to Api Gateway, it is much simpler, cheeper and easier to use but will not support bunch of features that REST API supports. Model Validations in one of those un supported features. Here是比较。

所有验证都将驻留在应用程序代码中。

API HTTP APIs 不支持网关数据转换,但 REST APIs 支持。

你可以把API网关的HTTPAPI看作是RESTAPI的精简版。 HTTP API 的功能少于 REST API。因此,HTTP APIs 更快、更便宜。权衡是在使用 HTTP APIs 时可供选择的功能较少。

如果您想使用数据转换,则需要使用 REST API。如果您更喜欢使用 cheaper/faster HTTP API,您需要自己进行数据转换(例如,您自己用 Lambda 编写的代码)。