刚才回了qiezi的一篇帖子,发现回到他的blog里去了,不如新开一篇:
引用
我总觉得REST应该用于提供数据而不是页面
如果能够套用CRUD,那么REST就是既能提供数据(或者用REST的术语:resource)又能提供页面。
GET /posts # list, for display only
GET /posts/new # new, for display only
GET /posts/1;edit # edit, for display only
POST /posts # update, for resource
GET /posts/1 # view, for both display and resource
PUT /posts/1 # update, for resource
DELETE /posts/1 # destroy,for resource
为什么CRUD好,除了可以理清思路,更是为了可以用REST标准来创建一套既能...又能...的机制。这样为你的网站/程序自动提供API了。
设想REST流行起来,新网站都缺省地提供符合REST标准的API,整个internet就是一个巨大的类库,这才是真正的webOS。这才是REST的魅力所在,是激动人心的地方,不是仅仅为了某单个项目的优化。
再引申以下:
web calendar,web office,web mail,web rss reader都有些很不错的小公司提供的服务,人气也不错,但是google开始做这些东西的时候,他们就消失了(或者被google收购了)。因为虽然功能有些差距,但google把他们集成了呀。集成的便利性很有诱惑力,所以那些focus的小公司就无以为继了。有人说google是下一个microsoft,只不过把东西都搬到网上去了,这个垄断的趋势已经有苗头了。但是如果那些service provider都用REST的标准,就像上面说的,internet就是一个巨大的类库(就像DHH的那个ppt的名字:world of resources),那么垄断就不那么容易了。我们程序员也能得到更大的自由,册那,那是多么大的自由啊。我还能记得当我学会用vba控制ms office的喜悦。我用更大的喜悦期盼着这个world of resources。
如果从这个角度来理解CRUD的意义,是不是就简单一些了?再读一下Nested Resource的描述和定义。然后闭上眼睛想一想MFC,MSO(office库)或者你用过的任何API,他们是不都是resource或者nested resource的crud啊?操作系统都是crud接口的,什么不能呢?也许,你的某一个应用crud的不顺,我也不鼓吹所有的都要crud。人家说crud很伟大,为什么?要从world of resource来理解。
顺便说一句,vba是ms最好的macro语言。无疑,ruby是internet最好的macro语言。
分享到:
- 2006-12-16 14:09
- 浏览 6344
- 评论(9)
- 论坛回复 / 浏览 (9 / 8850)
- 查看更多
相关推荐
Does the REST architectural style really present a viable alternative for building distributed systems and enterprise-class applications? In this insightful book, three SOA experts provide a down-to-...
REST continues to gain momentum as the best method for building web services, leaving many web architects to consider whether and how to include this approach in their SOA and SOAP-dominated world....
DHC by Restlet is designed and developed by developers for developers to make direct HTTP/REST resource discovery, manipulation and testing more easily. Our long-term mission is to bring you the best ...
要构建rest-server二进制文件,请运行CGO_ENABLED=0 go build -o rest-server ./cmd/rest-server 码头工人 建立影像 将rest-server二进制文件放在当前目录中,然后运行: docker build -t restic/rest-server:...
本文说明了Ajax/REST应用程序的开发时特性的问题。其目标是为那些有兴趣在实际应用程序中使用Ajax的读者解答两个重要的问题:是否应该在自己的IT应用程序中使用Ajax技术吗?如果答案是肯定的,那么应怎样来提高成功...
卡夫卡休息代理用go编写的独立Kafka rest代理。 任何实例都会在zookeeper上注册自己(注册名称空间是可配置的)并连接到所有kafka代理。 您可以将<URI>:<PORT>/topic/<TOPIC> uri上的内容作为邮件正文传递给kafka...
smartthings-rest-api:SmartThings REST API
rest-api:Python Rest API
pip install flask-rest-paginate 用法 在您的应用中,按如下所示添加扩展名 from flask import Flask from flask_restful import Api from flask_sqlalchemy import SQLAlchemy from flask_rest_paginate import ...
SpringMVC构建REST接口:第四篇 第一个REST风格的接口的源代码
FLUTTER REST API 如何在Flutter中集成REST API介绍: 在本文中,我们将学习如何在flutter应用程序中集成REST API。 众所周知,如今几乎所有应用程序都使用API来使用远程数据。 对于任何想让自己的未来变得...
use RestProxy\RestProxy; use RestProxy\CurlWrapper; $proxy = new RestProxy( Request::createFromGlobals(), new CurlWrapper() ); $proxy->register('github', 'https://api.github.com'); $proxy->run(); ...
基于 REST 的 Web 服务:基础部分
下载,压缩解压等简易的jwt实现Websocket服务器框架多个http服务器端口发布websocket服务(可发布多个) websocket请求处理局部(建立连接,销毁连接,接收消息等)工程介绍: masker-rest-framework:http服务器...
RestApi 基于: : 要启动新的Phoenix应用程序: 使用mix deps.get安装依赖mix deps.get 使用mix phoenix.server启动Phoenix端点 现在,您可以从浏览器访问localhost:4000 。 发布到API curl -H "Content-Type:...
java源码收集 depthgoods
GraphQL2REST 从现有的GraphQL API自动生成RESTful API GraphQL2REST是一个Node.js库,可读取您的GraphQL模式和用户提供的清单文件,并自动生成具有完全RESTful HTTP路由(即成熟的REST API)的Express路由器。 为...
REST-demos:REST演示应用程序
apply_rest_docs:REST文档
python-simple-rest-client:适用于python 3.6+的简单REST客户端