REST,让 web 变得更美好!

REST,让 web 变得更美好!

What is Representational State Transfer (REST)?
Building Web Services the REST Way
Python Web Frameworks and REST
Dispatching in a REST Protocol Application
selector: a RESTful url dispatcher.
robaccia: a RESTful web framework. (yes, the mini web framework!)
wsgicollection: make robaccia even more RESTful.
use JSON RESTfully
Using REST with Ajax


  1. 什么是REST?REST是网络系统的一种 architecture style,我们的 web 便是这种 architecture style 一个好例子。万物皆资源,web便由这些资源所组成。每项资源都有其标识,即URL。当我们通过客户端访问一个URL,相应资源的一个 representation 便会返回。于是客户端的 state 便发生了改变。所以叫做 Representation State Transfer!而服务器不保存 state ,这使得客户端的请求是相对独立的,只要客户端的 state 不变,那么客户端的相同请求总是得到相同的 representation

  2. 设计 RESTful 的web服务的原则
    • 标识所有需要暴露的资源,
    • 为每一个资源设计URL,资源应该是名词而非动词,比如应该使用 http://www.parts-depot.com/parts/00345 而非 http://www.parts-depot.com/parts/getPart?id=00345
    • 根据用户能否修改还是只能查看资源对资源进行分类,前者只能进行 GET 请求,后者可以使用 POST、PUT 和/或 DELETE
    • 没用孤岛。所有资源的 representations 应该通过超链接联系起来


  3. 最后看点 代码

 

posted @ 2008-04-20 13:07  lsjwzh  阅读(241)  评论(0编辑  收藏  举报