前两天发给移动端同事的布道内容, Martin Fowler的总结还是比较到位的,遗憾的是国内大多数所谓Restful可能连level2都达不到。
Dr. Leonard Richardson put together a maturity model that interprets various levels of compliance with RESTful principles, and grades them. It describes 4 levels, starting at level 0. Martin Fowler has a very good write-up on the maturity model
Level 0: the Swamp of POX - at this level, we’re just using HTTP as a transport. You could call SOAP a Level 0 technology. It uses HTTP, but as a transport. It’s worth mentioning that you could also use SOAP on top of something like JMS with no HTTP at all. SOAP, thus, is not RESTful. It’s only just HTTP-aware.
Level 1: Resources - at this level, a service might use HTTP URIs to distinguish between nouns, or entities, in the system. For example, you might route requests to /customers, /users, etc. XML-RPC is an example of a Level 1 technology: it uses HTTP, and it can use URIs to distinguish endpoints. Ultimately, though, XML-RPC is not RESTful: it’s using HTTP as a transport for something else (remote procedure calls).
Level 2: HTTP Verbs - this is the level you want to be at. If you do everything wrong with Spring MVC, you’ll probably still end up here. At this level, services take advantage of native HTTP qualities like headers, status codes, distinct URIs, and more. This is where we’ll start our journey.
Level 3: Hypermedia Controls - This final level is where we’ll strive to be. Hypermedia, as practiced using the HATEOAS ("HATEOAS" is a truly welcome acronym for the mouthful, "Hypermedia as the Engine of Application State") design pattern. Hypermedia promotes service longevity by decoupling the consumer of a service from intimate knowledge of that service’s surface area and topology. It describes REST services. The service can answer questions about what to call, and when. We’ll look at this in depth later.
【 在 playniuniu 的大作中提到: 】
: RESTful 简单说起来,就是用 http 操作数据库,数据库CRUD,分别对应http的 get, post, put, delete 等不同方法
: 真正使用的时候,前端 js 通过 ajax 调用 get, post, put, delete,通过http 协议对后端数据进行不同的操作
: 这里需要注意的是,restful设计的时候是和资源相关,和动作无关,意思就是指你的 http 的 url 值应该含有 资源,不应该含有 get等行为
: ...................
--
修改:dhcn FROM 123.66.188.*
FROM 123.66.188.*