知识卡片
统一接口保持资源标识稳定
统一接口要求资源标识和表示方式对客户端保持一致:每个 URI 唯一定位一个资源,已删除资源的 ID 不能转给另一个资源;序列化方式也应在 API 中一致。稳定标识让客户端可以依约定访问资源,不必猜测 URI 是否换了含义。
这张卡片看不懂?
这张卡片的反馈已满 10 条,暂时无法继续提交。
已有反馈 · 0 / 10 条
还没有人提交反馈。
原书出处
参考来源
- 位置:《Microservice APIs》第 4 章《Principles of REST API design》(源文件:_epub-src/OEBPS/Text/04.htm)
- 结论依据:原文要求统一接口和唯一 URI,用订单删除后不可重用 ID 的例子说明稳定标识,并提出一致序列化。
- 原始内容:Individual resources are identified by a Uniform Resource Identifier (URI), 4 and each URI must be unique and always return the same resource. For example, the URI /orders/8 represents an order with ID 8, and a GET request on this URI always returns the state of the order with ID 8. If the order is deleted from the system, the ID must not be reused to represent a different order.