知识卡片
状态码表达响应语义
客户端先用状态类别识别信息、成功、重定向、请求相关失败或服务相关失败,再用具体代码知道发生了什么。201 表达资源已创建,能给调用方比普通 200 更明确的反馈。
这张卡片看不懂?
这张卡片已通过人工审查,不再接受失败反馈。
已有反馈 · 0 条
还没有人提交反馈。
在整书笔记中的位置
原书出处 · 1 处
- Describing API responses 5.5 Status codes · 查看原书依据
The HTTP specification puts status codes into five categories, with each category being a range of codes. For example, the 200-299 (or 2xx) category includes those codes that indicate the request was successful. Table 5.7 lists those categories.
参考来源
- 位置:《Designing APIs with Swagger and OpenAPI》第05章《Describing API responses》(来源项目 book-source:extracted/Designing APIs with Swagger and OpenAPI/_epub-src/OEBPS/Text/ch05.htm,阅读块 99)
- 结论依据:原文用五个范围和 200、201 的区别说明状态在交互中的用途。
- 原始内容:The HTTP specification puts status codes into five categories, with each category being a range of codes. For example, the 200-299 (or 2xx) category includes those codes that indicate the request was successful. Table 5.7 lists those categories.