知识卡片

问题卡 · 2009.b

分页沿可用链接导航

理解等级:中级

大列表需要逐步浏览时,不能假定总页数或任意页号都能低成本计算。

分页接口提供first、previous、next、last、select以及exit/home等语义入口,消费者跟随实际返回的URL。首页可省略previous,尾页省略next;昂贵或难算的last也不必强求。

列表可仅返回摘要与详细项链接,按需计算下一页。直接跳第N页可能要求计算完整大列表;过滤后快照可稳定导航,但必须先付全量构建成本。页大小与总查询限制是两层控制。

这张卡片看不懂?

已有反馈 · 0 / 10 条

    还没有人提交反馈。

    在整书笔记中的位置

    原书出处 · 1 处

    • 超媒体工作流 · 查看原书依据

      A good way to add “pagination” support to your service interface is to expose a fixed set of actions that can be applied to any resource list. This set of actions should include not only list navigation actions (first, previous, next, and last) but also actions to pick a particular item from the list and even exit the list navigation.

    参考来源

    - 位置:《RESTful Web API Patterns and Practices Cookbook Connecting and Orchestrating Microservices and Distributed Data (Mike Amundsen)》第7章《超媒体工作流》§7.11(来源项目:book-sources;源文件:extracted/RESTful Web API Patterns and Practices Cookbook Connecting and Orchestrating Microservices and Distributed Data (Mike Amundsen)/_epub-src/OEBPS/ch07.xhtml) - 结论依据:原文以分页接口提供first、previous、next、last、select以及exit/home等语义入口,消费者跟随实际返回的URL的方式说明该用途;同节示例与讨论补充了卡内条件和边界。 - 原始内容:A good way to add “pagination” support to your service interface is to expose a fixed set of actions that can be applied to any resource list. This set of actions should include not only list navigation actions (first, previous, next, and last) but also actions to pick a particular item from the list and even exit the list navigation.