Thursday, January 14, 2010

RESTful.........what?

What is REST?
wiki says representational state transfer is a style of software architecture for distributed hypermedia systems..  The constraints described are :
  • Client Server
  • Stateless
  • Cacheable
  • Layered system
  • Code on demand
  • Uniform interface
RESTful web services (aka RESTful web API);
  Comprised of 3 aspects - URI, MIME type supported, operations supported using HTTP methods.

Public implementations : Atom publishing protocol, Suns cloud API etc

Arent all our web applications RESTful then?
So what does it mean for a java developer?
Answers here are quite close
http://www.rubyrailways.com/great-ruby-on-rails-rest-resources/

Everything should be treated as a resouce on the web (not a page). The clear advantage of this is that the same URL can serve content in different formats. Currently most of the sites serve html pages, but they dont work on a mobile or a client expecting xml feeds,etc.

Think of REST as a sentence
• HTTP Methods are verbs
• URIs are nouns
• This grammar is currently being abused by existing websites.

Action implied in the URI
• Implied action conflicts with HTTP method
Conflicting
GET http://addressbook/contacts/destroy/1

Ref:
http://en.wikipedia.org/wiki/Representational_State_Transfer
http://www.rubyrailways.com/great-ruby-on-rails-rest-resources/

No comments: