知识卡片
超媒体链接需权衡成本
为每个响应附操作链接会增加设计与运行成本:不同角色权限、资源状态都影响可返回的操作;链接列表也可能放大载荷。设计时应比较它与 API 文档已经提供的信息,按客户端导航需求选用,避免无差别地把所有端点塞进响应。
这张卡片看不懂?
这张卡片的反馈已满 10 条,暂时无法继续提交。
已有反馈 · 0 / 10 条
还没有人提交反馈。
原书出处
参考来源
- 位置:《Microservice APIs》第 4 章《Principles of REST API design》(源文件:_epub-src/OEBPS/Text/04.htm)
- 结论依据:原文逐项列出文档信息重叠、角色权限、资源状态与大载荷问题,并建议权衡链接的实际收益。
- 原始内容:The information supplied by hyperlinks is already available in the API documentation. ... Therefore, it’s necessary to return different lists of related links to different users according to their permissions. However, this level of flexibility introduces additional complexity in our API designs and implementations and couples the authorization layer with the API layer. ... Finally, in some APIs, the list of related links may be large and therefore make the response payload too big