知识卡片
响应状态应保留业务区别
处理器应把缺键映射为404,把意外失败映射为服务器错误,成功则写入相应状态和内容。不能把所有非nil错误统一当成500,否则调用者丢失业务结果。原文Get需求列出404,但样例并未实现该分支;应按契约补足而非把样例当作已满足需求。
这张卡片看不懂?
这张卡片的反馈已满 10 条,暂时无法继续提交。
已有反馈 · 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