Hypermedia, links and verbs
Today I was talking to Jose Valim, about hypermedia and how links could be represented in many ways using several different media types.
One of the most common question that appears on rest-discuss every now and then is why atom, and similar, links do not include an attribute that tells the client which verb should be used to access that resource, as html does:
form action="..." method="post"
Actually, html uses the method attribute in a form not to tell how to access a resource: a resource is always retrieved through GET, always created through PUT and POST, always deleted through DELETE.
Html uses that attribute to allow the server notifies which parameters are necessary and which media type to use to retrieve (GET) or create (POST) a resource.
We typically think that the verb is necessary because otherwise clients would not know that they are supposed to do a post, i.e. for publishing a blog entry:
link href="/posts/1/publish" rel="publish" verb="POST"
That’s because the link relation identifies an action, not a resource. Thinking about resources and sticking to the uniform interface when it comes to verbs, we would have:
link href="/posts/1/publish" rel="publication"
It is quite clear that POSTint to such URI would create something, while GETting would retrieve.
In those cases, there is no need for explicit verb declaration on the link (or form).
There *might* be a need when specifying query parameters or writing input elements within a form.