如何“存储" REST原型不是在创建新资源和新URI? [英] How "store" REST archetype isn't creating a new resource and a new URI?
问题描述
REST API设计表明存在四种资源原型:文档,集合,存储和控制器.
REST API design indicates there are four resources archetypes: document, collection, store and controller.
商店不创建新资源;因此,商店永远不会生成新的URI.
Store do not create new resources; therefore a store never generates new URIs.
一个例子:
PUT /users/12245/favorites/boston-celtics
用户将波士顿凯尔特人队加入了他的收藏夹列表.
A user added Boston Celtics to his favorites list.
但是这不是在创建新资源吗?以及如何不生成新的URI?
But how that isn't creating a new resource ? and how it isnt generating a new URI?
推荐答案
商店不会自行创建资源.商店的用户创建端点/URI.
A store does not create a resource on its own. The user of the store creates endpoints / URIs.
收藏夹与商店之间的对比
The contrast is between a Collection and a Store
集合 集合资源是服务器管理的资源目录.客户可以提出要添加到集合中的新资源.但是,由集合决定是否创建新资源.收集资源选择要包含的内容,并确定每个包含的资源的URI.
Collection A collection resource is a server-managed directory of resources. Clients may propose new resources to be added to a collection. However, it is up to the collection to choose to create a new resource, or not. A collection resource chooses what it wants to contain and also decides the URIs of each contained resource.
商店 商店是客户端管理的资源存储库.商店资源允许API客户端:放入资源,取出资源并决定何时删除它们.
Store A store is a client-managed resource repository. A store resource lets an API client: put resources in, get them back out, and decide when to delete them.
这篇关于如何“存储" REST原型不是在创建新资源和新URI?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!