知识卡片

普通读书笔记卡 · 3436

单项与集合端点

理解等级:初级

REST API 的端点可以指向一个资源,也可以指向资源集合。例如 GET /orders/8 定位一笔订单,GET /orders 定位订单集合。区分两者有助于说明请求面向的资源范围;具体动作仍由 HTTP 方法表达。

这张卡片看不懂?

已有反馈 · 0 条

    还没有人提交反馈。

    原书出处

    参考来源

    - 位置:《Microservice APIs》封二《API 优先开发说明》(源文件:_epub-src/OEBPS/Text/IFC.htm) - 结论依据:原文直接区分 singleton 与 collection 两类端点,分别以单笔订单和订单集合的 GET 路径举例,并在后文说明动作由 HTTP 方法指示。 - 原始内容:REST APIs are structured around endpoints. We distinguish between singleton endpoints, such as GET /orders/8 , and collection endpoints, such as GET / orders . REST APIs leverage the semantics of HTTP methods to indicate actions (such as POST to create resources), and they use HTTP status codes that signal the result of processing the request (such as 200 for successful responses).