REST isn't what you think it is, and that's OK
intridea.com
intridea.com
<post>
<id>1</id>
<title>This is a post</title>
<comments></comments>
<author_id>100</author_id>
</post>
When you consume this resource, you end up having to munging database foreign key IDs into an URL string. For example, if I want more data about the author of the post above, I'd have to grab <author_id/> and plug into another endpoint, like /authors/:author_id. Who knows if /authors is the correct endpoint? Even if it was, if that endpoint changes, it could break the URLs that I munged together.These "RESTful" implementations should really look like is the following:
<post href="/posts/1">
<id>1</id>
<title>This is a post</title>
<comments href="/posts/1/comments"/>
<author href="/authors/100"/>
</post>
Given such a format, I don't have to guess what the endpoints are for associated resources; I just look at the href and grab the resource if I want it.A collection could include dataset navigation information, such as:
<posts>
<link rel="prev" href="/posts/?start_id=51&items=50"/>
<link rel="next" href="/posts/?start_id=101&items=50"/>
<post href="/posts/1">
<id>1</id>
<title>This is a post</title>
<comments href="/posts/1/comments"/>
<author href="/authors/100"/>
</post>
<!-- more posts here... -->
</posts>
Now I can implement a less breakable client that doesn't need to munge URL endpoints with database foreign keys. Furthermore, I can navigate through datasets by following the <link rel/> tags.The questions that need to be answered are how would true REST be different, and why would I want to spend my precious time learning about it and implementing it?
This is a pretty good one stop shop for the first question: http://www.nordsc.com/ext/classification_of_http_based_apis....
Martin Fowler's article on the subject is good too: http://martinfowler.com/articles/richardsonMaturityModel.htm...
And this article shows a basic "hello world" implementation of REST, and explains the benefits: http://www.infoq.com/articles/subbu-allamaraju-rest
I appreciate the author's enthusiasm towards REST, but I would prefer to discuss the technical merits rather than engage in justification and categorization of what's out there right now. Yeah, it's not REST, and yeah people are going to call it REST anyway in certain contexts. But in the context of architectural design we have clear definitions about what REST is, and there's no need to muddy the waters.
The first sentence of your quote say that all prior knowledge should be about media formats (like the html specification, microformats, the PNG image format…).
From there, the medium itself should provide enough clue for the client to go on. For instance, anchor links in html says you can GET a resource at the specified URI. Other media formats could provide other clues.
To sum up, the only things you can specify a-priori are media formats. URIs and protocols should be interchangeable, so you can update and deprecate them. I think the main goal of REST is to concentrate coupling on media formats alone. Hopefully, most media formats are (or will be) standardized, effectively reducing coupling. Basically, REST architectures are for the long term.
Another example drawn from the article: if the blog posting service provides each post under a uri like /posts/{post-id}, the client of the service shouldn't have to know the uri structure. Instead, /posts/ should be a resource, and it should contain hyperlinks to all of the /posts/{post-id} uris that are available. There would probably be some metadata about each one as well, such as a title, to enable clients to figure out which one they want to follow.
Instead of RESTful, why not the more accurate RESTy or RESTish? Because it doesn't sound good.
I highly recommend checking out JSON-RPC 2.0 or just rolling your own to see how easy it can be. The one I wrote is 200 lines of code and slightly more robust than you actually need to have a working RPC server (I added automatic casting and support for optional parameters with defaults, just for my convenience.)
And I came to the exactly same conclusions. Couldn't you have written this 4 weeks earlier?