【发布时间】:2017-04-09 19:25:20
【问题描述】:
我们将数据存储在 Google Cloud Datastore 中。我们想为我们的用户提供 API。 我们 API 的分页规范与 github API 一样基于标头。我们希望用户使用页面参数。
分页规范
e.g.
Link: <https://api.github.com/search/code?q=addClass+user%3Amozilla&page=15>; rel="next",
<https://api.github.com/search/code?q=addClass+user%3Amozilla&page=34>; rel="last",
<https://api.github.com/search/code?q=addClass+user%3Amozilla&page=1>; rel="first",
<https://api.github.com/search/code?q=addClass+user%3Amozilla&page=13>; rel="prev"
https://developer.github.com/guides/traversing-with-pagination/
API
End-Users <--- Backend Code (PHP) <--- Google Cloud Datastore
如您所知,Google Cloud Datastore 建议使用游标来提高性能和成本。但我们不希望最终用户使用光标。是否可能最终用户使用整数页码而不是游标,而游标用于后端?
我们使用谷歌的 PHP 客户端。
【问题讨论】: