知识卡片
退役端点按去向选状态码
旧 URI 已永久失效且无替代时,可用 410 明确资源不再可用;若永久迁往新 URI,可考虑 301 并给出新位置。客户端是否自动重定向、HTTP 方法是否保留仍须核验,不能把所有退役统一映射到单一状态码。
这张卡片看不懂?
这张卡片的反馈已满 10 条,暂时无法继续提交。
已有反馈 · 0 / 10 条
还没有人提交反馈。
原书出处
参考来源
- 位置:《Microservice APIs》附录 B《Managing an API’s life cycle》(源文件:_epub-src/OEBPS/Text/B.htm)
- 结论依据:原文将 410 用于已退役资源,301 用于迁往新 URI,支持按去向区分响应。
- 原始内容:A good option is the 410 (Gone) status code. We use the 410 status code to signal that the requested resource no longer exists for a known reason. In some circumstances, 301 (Moved Permanently) might be useful. We use the 301