What exactly is RESTful programming?
相关问题
- Angular RxJS mergeMap types
- Design RESTful service with multiple ids
- Axios OPTIONS instead of POST Request. Express Res
- Plain (non-HTML) error pages in REST api
- Google Apps Script: testing doPost() with cURL
相关文章
- C#使用http访问网络,有办法用指定网卡访问网络嘛?
- Is a unicode user agent legal inside an HTTP heade
- Got ActiveRecord::AssociationTypeMismatch on model
- Multiple parameters in AngularJS $resource GET
- git: retry if http request failed
- Flutter - http.get fails on macos build target: Co
- Global Exception Handling in Jersey & Spring?
- REST search interface and the idempotency of GET
REST === HTTP analogy is not correct until you do not stress to the fact that it "MUST" be HATEOAS driven.
Roy himself cleared it here.
A REST API should be entered with no prior knowledge beyond the initial URI (bookmark) and set of standardized media types that are appropriate for the intended audience (i.e., expected to be understood by any client that might use the API). From that point on, all application state transitions must be driven by client selection of server-provided choices that are present in the received representations or implied by the user’s manipulation of those representations. The transitions may be determined (or limited by) the client’s knowledge of media types and resource communication mechanisms, both of which may be improved on-the-fly (e.g., code-on-demand).
[Failure here implies that out-of-band information is driving interaction instead of hypertext.]
I would say RESTful programming would be about creating systems (API) that follow the REST architectural style.
I found this fantastic, short, and easy to understand tutorial about REST by Dr. M. Elkstein and quoting the essential part that would answer your question for the most part:
Learn REST: A Tutorial
I don't think you should feel stupid for not hearing about REST outside Stack Overflow..., I would be in the same situation!; answers to this other SO question on Why is REST getting big now could could ease some feelings.
Talking is more than simply exchanging information. A Protocol is actually designed so that no talking has to occur. Each party knows what their particular job is because it is specified in the protocol. Protocols allow for pure information exchange at the expense of having any changes in the possible actions. Talking, on the other hand, allows for one party to ask what further actions can be taken from the other party. They can even ask the same question twice and get two different answers, since the State of the other party may have changed in the interim. Talking is RESTful architecture. Fielding's thesis specifies the architecture that one would have to follow if one wanted to allow machines to talk to one another rather than simply communicate.
Those answers giving examples of linked resources is great but only half the picture.
So, imagine you're designing a website. You write a story,
I want to be able to search for an address by postcode so that I can choose a shipping address
Then you'd build the site to take the user on that journey and try and link the pages together in a workflow.
A website design that took them to an address lookup but then left them to copy the address into the clipboard and then return to the shipping address form wouldn't be very useable.
A REST API uses patterns we take for granted on the web for a machine-machine interaction.
The search for a postcode feature shouldn't be
base/addresses/{postcode}
and a collection comes back, even if each address links to a full address and some edit links, because that's a dead end; the API consumer would need to guess how to use the address.Instead the motive for the feature should be built-in to the flow in which its used such that the journey ends back at the start:
It's a user journey and at the end you can see the impact of the flow on the order.
The HTTP request/response isn't strictly part of REST but I don't think anyone has ever seen a non-HTTP REST application.
Now those URLs could be any set of characters, they're just identifiers, I made them pretty because they make sense to people. A machine would use the
rel
to work out what they do, not depend on a readablehref
.One of the best reference I found when I try to find the simple real meaning of rest.
http://rest.elkstein.org/
RESTful (Representational state transfer) API programming is writing web applications in any programming language by following 5 basic software architectural style principles:
In other words you're writing simple point-to-point network applications over HTTP which uses verbs such as GET, POST, PUT or DELETE by implementing RESTful architecture which proposes standardization of the interface each “resource” exposes. It is nothing that using current features of the web in a simple and effective way (highly successful, proven and distributed architecture). It is an alternative to more complex mechanisms like SOAP, CORBA and RPC.
RESTful programming conforms to Web architecture design and, if properly implemented, it allows you to take the full advantage of scalable Web infrastructure.