什么是休息,它的优势是什么 [英] what is rest,and what is its advantage

查看:48
本文介绍了什么是休息,它的优势是什么的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在谷歌上搜索了有关休息的文档,但我不确定我是否理解它.

I have googled about the docs of rest, but I am not exactly sure I understand it.

我在rest中看到的是它的URL是干净的,例如:

What I can see in rest is that its URL is clean, for example:

http://host/webservice.asmx?name=xname&type=xtype

如果是 REST 风格,可能是:

If in REST style, it is perhaps:

http://host/webservice.asmx/xname/xtype

不是吗?

所以我只是发现网址更干净,但我找不到任何其他优点.

So I just found the URL is cleaner, but I can not find any other advantages.

谁能告诉我更多?

我还有一些问题:

  1. 我发现一些基于 Ruby-on-Rails 构建的应用程序都使用了干净的 URL,例如:

  1. I found that some application built on Ruby-on-Rails all use the clean URL, for example:

http://xxx/blog/list

http://xxx/blog/edit/1

http://xxx/blog/1

那么他们之间有什么关系吗?

So is there any relationship between them?

网址重写

URL 重写是实现 REST 的方法之一吗?

Is URL rewriting one of the ways to implement REST?

我们有一些基于 ASP.NET 的 Web 服务,有什么方法可以将其更改为 REST 架构吗?

We have some web service built on ASP.NET, are there any ways to change that to a REST architecture?



更新:

我已经阅读了这篇文章(rest-to-my-wife),似乎使用http(post/get/put/delete)提供的动词我们可以使用相同的url对资源进行不同的操作,只需放置http正文中的相关数据;例如,我想创建一个新订单:

I have read this article(rest-to-my-wife),it seems that using the verbs provided by http(post/get/put/delete) we can do different operation to a resource using the same url just put the realated data in the http body; for example,I want to create a new order:

POST http://www.store.com/order,
<purchase-order>
  <item> ... </item>
</purchase-order>

但我还有一些问题:

1) 我们如何在页面中设置 http 正文?

另一个例子,我想删除一个订单:

ANother example,I want to delete an order:

删除http://www.store.com/order/1

但是在页面中,url只是一个链接,

But in the page,the url is just a link,

Mabye 是这样的:

Mabye it is like this:

删除此订单

它是静态的,我们如何告诉浏览器在将这个url发送到服务器时,它应该使用删除"方式而不是获取"方式?

it is static,how can we tell the browser that when it send this url to the server,it should use the "delete" manner rather than "get"?

2) 是否会导致服务器端的额外工作?

由于我们可能会使用不同的 http 方法(get/post...)向服务器发送相同的 url,因此服务器可能需要解析 http header 和 body 以确保用户想要为此执行什么操作url(也许使用 'resource' 而不是 'url' 更好,但我分不清 url 和 uri 和 resouce 之间的区别)?

Since we may send the same url with different http method(get/post...) to the server,so the server may have to parse the http header and body to make sure what operation the user want to do for this url(maybe using the 'resource' instead of 'url' is better,but I can not tell the difference between url and uri and resouce)?

以相同的网址为例:

http://www.store.com/order/1

如果服务器发现http方法是get,他可能知道哦,这家伙只是想获取id为1的订单的信息",如果方法是delete",他知道哦,这家伙要删除id为1的订单".

If the server find that the http method is "get",he may know that "oh,this guy just want to get the info of the order whose id is 1",if the method is "delete",he know "oh,this guy want to delete the order whose id is 1".

所以这种方式似乎将额外的工作从客户端转移到服务器端.

So it seems that this manner will transfer the extra work from client side to server side.

我的意思是在客户端的 url 都是一样的,它更容易,但对于服务器端它需要更多的工作,这是真的吗?

Which I mean that in the client the url is all the same,it is easier,but for the server side it need more work,is this true?

推荐答案

HTTP 本身就是一个 REST 实现.URL 的构建方式与此无关.REST 是一种在每个请求中传递信息的方式,而不是永久打开连接.

HTTP is itself a REST implementation. The way the URL is built has nothing to do with it. REST is a way in which information is passed in each request, instead of having a permanently open connection.

这篇关于什么是休息,它的优势是什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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