首先,我想解释一下我所创造的Hierarchical REST API和的含义。Normalized REST API
http://www.example.com/customers/12345/orders)customer包含an order)
http://www.example.com/customers/12345{
"name": "John Doe",
"orders": [{
"id": 1,
"price": 10,
"delivered": true
}, {
"id": 2,
"price": 11,
"delivered": false
}
]
}
Run Code Online (Sandbox Code Playgroud)
http://www.example.com/customers/12345/ordershttp://www.example.com/customers/12345/orders/1http://www.example.com/customers/12345/orders?accepted=truehttp://www.example.com/customershttp://www.example.com/customers?firstName=Johnhttp://www.example.com/customers/12345http://www.example.com/orders/1http://www.example.com/customers/12345{
"name": "John Doe",
"orderIds": [1, 2]
}
Run Code Online (Sandbox Code Playgroud)
我认为这两种方法都有各自的优点和缺点
http://www.example.com/customers/12345)http://www.example.com/customers/12345可以http://www.example.com/stores/1包含相同的order数据)orders某个特定的内容中检索所有内容customer,至少需要客户端发出 2 个请求)我的问题是:
Hierarchical REST API和有术语Normalized REST API吗?是否有分层 REST API 和规范化 REST API 的术语?
不。
哪一种更符合 REST API 指南?
他们俩都“很好”。
考虑一下万维网,以及我们如何向浏览器传递 CSS 指令。我们可以将 CSS 直接嵌入到 HTML 页面中吗?是的。我们可以链接到通过不同资源获取的 CSS 吗?是的。
这两种方法都“符合 REST API 指南”。是的 - 更准确地说,它们之所以有效,是因为 HTML 是一种通用的标准化媒体类型,具有有关 CSS 引用如何工作的规则;每个人都以同样的方式理解这些规则。
| 归档时间: |
|
| 查看次数: |
1618 次 |
| 最近记录: |