简体   繁体   English

api网关和lambda分页

[英]api gateway and lambda pagination

I am trying to do an api using AWS Api Gateway as a Lambda trigger.我正在尝试使用 AWS Api 网关作为 Lambda 触发器来执行 api。
Lambda is implemented in python 3.7. Lambda在python 3.7中实现。
When I submit a POST to api URL, a Lambda is triggered and the code implemented returns an array of JSON.当我向 api URL 提交 POST 时,会触发 Lambda 并且实现的代码返回 JSON 的数组。
Example of response:响应示例:

[
  {
    "k1": 1,
    "k2": 2
  },
  {
    "k3": 3,
    "k4": 4
  },
  {
    "k5": 5,
    "k6": 6
  },
  {
    "k7" : 7,
    "k8" : 8
  }
]

In example, lambda response will be a list of 4 json objects.例如,lambda 响应将是 4 个 json 对象的列表。 I want to paginate the response to send one object in each page.我想对响应进行分页以在每一页中发送一个 object。
Is it possible?是否可以? How can I told the api or lambda which is the complete array?我如何告诉 api 或 lambda 哪个是完整的数组?

After investigate this topic, I wasn't able to paginate the response in the api so I paginate the response in my code.调查此主题后,我无法对 api 中的响应进行分页,因此我在我的代码中对响应进行了分页。 My code reads data from database so I pass a token to api to check in which line of database I am reading我的代码从数据库中读取数据,所以我将一个令牌传递给 api 以检查我正在读取的数据库行

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM