如何“存储"REST 原型没有创建新资源和新 URI? [英] How "store" REST archetype isn't creating a new resource and a new URI?

查看:21
本文介绍了如何“存储"REST 原型没有创建新资源和新 URI?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

REST API 设计表明有四种资源原型:文档、集合、存储和控制器.

REST API design indicates there are four resources archetypes: document, collection, store and controller.

Store 不创建新资源;因此,商店永远不会生成新的 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.

Collection 和 Store 的对比

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆