RESTful Web服务的URI [英] URI for RESTful Web Services

查看:110
本文介绍了RESTful Web服务的URI的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图了解URI应该是什么样子。查看此参考: http://en.wikipedia.org/wiki/Representational_State_Transfer#RESTful_web_services,我对POST应该如何工作感到有点困惑。

I'm trying to understand how URIs are supposed to look like. Looking at this reference: http://en.wikipedia.org/wiki/Representational_State_Transfer#RESTful_web_services, I am a bit confused by how POST is supposed to work.

给出的例子如下: http://example.com/resources/142 。我将142关联为资源中的特定项目(因此,可以删除,更新或获取表示)。在创建集合的新成员的上下文中,142让我感到困惑。 142意味着什么?在数据库方面,这会是新成员的身份吗? (我将这些与CRUD联系起来。)

The example given is this: http://example.com/resources/142. I'm associating "142" as a specific item in "resources" (thus, one could delete, update, or get the representation). The "142" is confusing to me in the context of creating a new member of a collection. What does the 142 mean? In terms of databases, would that be the new member's id? (I'm associating these with CRUD).

任何人都可以澄清吗?

推荐答案

我也不太确定我也明白,但据我所知,如果你发布到 http://示例你正在将142视为一个集合,并且会在该集合中添加另一个项目。

I'm not quite sure I understand either, but I understand that if you POST to http://example.com/resources/142 you are treating 142 as if it were a collection in it's own right and would be adding another item to that collection.

if它是www.blog.com/blog/142

If it were www.blog.com/blog/142

142可能是用户博客,POST可能会创建一个新的博客帖子。

142 might be a users blog and a POST would possible create a new Blog Post.

PUT到142会更新整个142或创建博客(如果它不存在)。

a PUT to 142 would either Update the whole of 142 or create the blog if it didn't exist.

这篇关于RESTful Web服务的URI的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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