Guilhermesilveira's Blog

as random as it gets

Hypermedia, links and verbs

leave a comment »

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.


Written by guilhermesilveira

June 4, 2010 at 9:30 am

Posted in Uncategorized

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: