知识卡片
承诺稳定服务起点
服务迁址或内部URL变化时,消费者仍需要一个长期可靠的接入位置。
服务至少承诺一个长期有效的起点URL,使客户端可把它放进代码或配置;响应其余位置可随服务演进而变。起点可返回元数据、初始列表或登录入口,不要求所有客户端每次先访问它。
把起点放进文档,并用Link: <http://api.example.org/home>; rel="home"或正文链接公布。迁址仍须维护旧入口,例如用301及Location引导新位置。承诺多个稳定URL也可以,但每个都是长期兼容负担。
这张卡片看不懂?
这张卡片的反馈已满 10 条,暂时无法继续提交。
已有反馈 · 0 / 10 条
还没有人提交反馈。
在整书笔记中的位置
原书出处 · 1 处
- 超媒体服务 · 查看原书依据
The value of the URL could be something as simple as http://api.example.com/home or as complicated as http://v1.home.api.example.org/q1w2e3r4t5. What matters is that there is at least one location that consumers can memorize (i.e., write into their source code or configuration files) that will ensure that the API consumer can connect with the service API.
参考来源
- 位置:《RESTful Web API Patterns and Practices Cookbook》第5章《Hypermedia Services》(来源项目book-sources:extracted/RESTful Web API Patterns and Practices Cookbook Connecting and Orchestrating Microservices and Distributed Data (Mike Amundsen)/_epub-src/OEBPS/ch05.xhtml,配方5.1)
- 结论依据:原文将至少一个稳定URL定义为长期承诺,并演示home链接、迁址301和客户端自由访问其他位置。
- 原始内容:The value of the URL could be something as simple as http://api.example.com/home or as complicated as http://v1.home.api.example.org/q1w2e3r4t5. What matters is that there is at least one location that consumers can memorize (i.e., write into their source code or configuration files) that will ensure that the API consumer can connect with the service API.