[英]In a Rails API, is there a standard way to “paginate” or “chunk” large API requests responses?
Scenario: 场景:
/tasks.json
endpoint that serves all the Tasks. 我有一个带有/tasks.json
终结点的Rails API,可为所有任务提供服务。 I can easily "paginate" the number of tasks being sent so the endpoint uses something like /tasks.json?limit=10000&page=1
but how does the client know to send this? 我可以轻松地“分页”发送的任务数,以便端点使用类似/tasks.json?limit=10000&page=1
但是客户端如何知道发送此任务?
Is there a "standard" way to handle large requests like this and break them up naturally into chunks? 有没有一种“标准”的方式来处理这样的大请求,然后自然地将它们分解成大块?
Does each client need to handle this on their end manually? 每个客户都需要手动处理此问题吗?
Thanks! 谢谢!
You should use kaminari gem. 您应该使用kaminari宝石。 It handles all requests and paginates it. 它处理所有请求并分页。 It works both on Rails Api apps and rails standard apps. 它可以在Rails Api应用程序和Rails标准应用程序上使用。 https://github.com/kaminari/kaminari https://github.com/kaminari/kaminari
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.