知识卡片

问题卡 · 4545.g.8.f.1

响应状态应保留业务区别

理解等级:中级

处理器应把缺键映射为404,把意外失败映射为服务器错误,成功则写入相应状态和内容。不能把所有非nil错误统一当成500,否则调用者丢失业务结果。原文Get需求列出404,但样例并未实现该分支;应按契约补足而非把样例当作已满足需求。

这张卡片看不懂?

已有反馈 · 0 / 10 条

    还没有人提交反馈。

    在整书笔记中的位置

    原书出处 · 1 处

    • Building a Cloud Native Service · 查看原书依据

      It must respond with a 404 (Not Found) when a requested key doesn’t exist. It must respond with the requested value and a status 200 if the key exists. It must respond to unexpected errors with a 500 (Internal Server Error). All of the above requirements are implemented in the below keyValueGetHandler function. Note how

    参考来源

    - 位置:《Cloud Native Go》第05章《Building a Cloud Native Service》(来源项目book-sources;源文件:extracted/Cloud Native Go (Matthew A. Titmus)/_epub-src/OEBPS/ch05.xhtml) - 结论依据:处理器应把缺键映射为404,把意外失败映射为服务器错误,成功则写入相应状态和内容。原文相应定义、示例或限制为此结论提供依据;补充纠错与版本边界在正文就近标明。 - 原始内容:It must respond with a 404 (Not Found) when a requested key doesn’t exist. It must respond with the requested value and a status 200 if the key exists. It must respond to unexpected errors with a 500 (Internal Server Error). All of the above requirements are implemented in the below keyValueGetHandler function. Note how