RE: How much REST should your Web API get?

"Markus Lanthaler" <[email protected]> Sat, 4 May 2013 18:47:49 +0200
Newsgroups gmane.comp.web.services.rest
Message-ID <[email protected]>
On Saturday, May 04, 2013 5:54 PM, Mike Schinkel wrote:
> On May 4, 2013, at 9:35 AM, Jørn Wildt <[email protected]> wrote:
> > Allow me to disagree with you here. Why do you consider this as
> > being stateful? I don't see how this has anything to do with it.
> 
> Unless everything in your API can be done with at most two HTTP
> requests (I had not considered that potential) then it would seem your
> 3rd HTTP request would be assuming the state of your 1st request and
> thus your API not RESTful. If not, then how not stateful?

That has nothing to do with statelessness as it describes what the client is
doing. The request to the server definitely contains all information and
doesn't rely on a shared state. So no, this is not stateful. Not even if
there are 100s of requests in between. The server and any intermediary
couldn't care less.

As long as that document is evaluated at run-time and not at design- or
compile-time everything is fine. Otherwise the result would be a client that
is tightly coupled to the server.


> > But isn't that exactly what I am proposing? We have one single
> > initial URL, the client GETs the service document representation
> > there and selects among the hyper media elements (the links) that
> > are present in the received representation.
> 
> Can everything in your API be done with one additional HTTP request
> after the home document? If yes, then sorry, I was assuming wrong.  If
> no, does it not fail this test?
> 
> The representation tells the client how to compose all transitions to
> the next application state.

Yeah. The emphasis is on "next application state". That doesn't require that
the next state is the final state. So there can be as many steps in between
as there are required... and every response to those intermediary requests
can link back to the home document - just in case the client hasn't seen it
yet. That's exactly the same as for normal websites.


--
Markus Lanthaler
@markuslanthaler