知识卡片

普通读书笔记卡 · 3547

退役端点按去向选状态码

理解等级:中级

旧 URI 已永久失效且无替代时,可用 410 明确资源不再可用;若永久迁往新 URI,可考虑 301 并给出新位置。客户端是否自动重定向、HTTP 方法是否保留仍须核验,不能把所有退役统一映射到单一状态码。

这张卡片看不懂?

已有反馈 · 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