再看REST

最近在看PM老张的《RESTful Web Services》,重新理解了一遍REST,以前的一些迷雾都变清晰了。

1,什么是REST?
"Representational State Transfer (REST) is a style of software architecture for distributed hypermedia systems
such as the World Wide Web. "

现实社会中的分布式超媒体系统的例子主要为www,但是我们不使用http、不与www交互也能构建遵循REST风格的软件系统。
REST是针对分布式超媒体系统的软件架构风格,这个前提很重要。
一般来说谈到REST风格时都是针对www应用的。

REST strictly refers to a collection of network architecture principles that outline how resources are defined
and addressed.
资源是REST的Central Principle。

"Representational State Transfer is intended to evoke an image of how a well-designed Web application behaves:
a network of web pages (a virtual state-machine), where the user progresses through an application by selecting
links (state transitions), resulting in the next page (representing the next state of the application) being
transferred to the user and rendered for their use."
当浏览器浏览访问一个url资源时,返回的页面即为该url资源的representation,这个representation给浏览器一个state,当
浏览器访问下一个url资源时,浏览器的state就transfer了。

2,REST的特性:
[b]Client-Server[/b]: a pull-based interaction style: consuming components pull representations. (Comet不遵守REST)
[b]Stateless[/b]: each request from client to server must contain all the information necessary to understand the request,
and cannot take advantage of any stored context on the server. (HTTP cookies不遵守REST)
[b]Cache[/b]: to improve network efficiency responses must be capable of being labeled as cacheable or non-cacheable.
[b]Uniform interface[/b]: all resources are accessed with a generic interface (例如HTTP GET/POST/PUT/DELETE).
[b]Named resources[/b]: the system is comprised of resources which are named using a URL.
[b]Interconnected resource representations[/b]: the representations of the resources are interconnected using URLs, thereby
enabling a client to progress from one state to another.
[b]Layered components[/b]: intermediaries, such as proxy servers, cache servers, gateways, etc, can be inserted between clients
and resources to support performance, security, etc.

3,,什么是RESTful?
Systems that follow Fielding's REST principles are often referred to as RESTful.
www就是一个RESTful的系统,因为www符合REST架构风格。
我们常说RESTful Rails,指的就是使用REST架构风格来做Rails开发,即使用HTTP动词GET/POST/PUT/DELETE和map.resources来开发
resources.rb是RESTful Rails的实现,参考[url=http://hideto.iteye.com/blog/94417]Rails源码研究之ActionController:八,resources[/url]

4,什么是RESTful Web Services?
RESTful Web Services即符合REST架构风格的轻量级Web Services。
RESTful Web Services以及ROA(REST oriented architecture)正是《RESTful Web Services》一书要讲的。
[url=http://hideto.iteye.com/blog/98602]Rails的RESTful Web Services实现[/url]

参考资源:
[url]http://en.wikipedia.org/wiki/Representational_State_Transfer[/url]
[url]http://rest.blueoxen.net/cgi-bin/wiki.pl?FrontPage[/url]
[url]http://www.xfront.com/REST-Web-Services.html[/url]
《RESTful Web Services》
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值