Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

REST and uptake of http PUT/DELETE  RSS feed

 
Katie Portwin
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Leonard and Sam,

I think I'm right in my understanding that proper use of the full set of HTTP Verbs is crucial to the REST model - Get for return resource, Delete for delete resource, Put for insert resource, Post for update resource?

This all seems very sensible. However, what do you think about the continued low uptake of Put and Delete by most programmers, (and the real/imagined patchy support - eg CGI.pm..) ?
 
Sam Ruby
author
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First, it is not crucial. You can get by with less. What I have found important, however, is that if you start with a clean design and then optimize and/or make tradeoffs generally works better than if you prematurely optimize for limitations in various tools. The current Ruby on Rails support for REST follows this model: a clean design with alternative interfaces for those who can't do PUT or DELETE.

PUT and DELETE support is wider than you might think. The one place where it is most notably lacking -- HTML Forms -- is also a place where not much WS-* interfaces work.
 
Leonard Richardson
author
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Katie,

We recommend using four verbs, but you don't have to. You can use GET
for safe operations, and POST for everything else. The catch is that
the client should POST to the same URI it GETs. That forces you to
think of your URIs as designating objects instead of operations. (To
quote page 221, "REST says you should use a uniform interface, but it
doesn't say which one.")

So, lack of four-verb support is not a catastrophe, but the four do
help people step back from how web applications are traditionally
designed, and think of URIs as designating objects. The flip side of
that is you're not going to start using PUT and DELETE unless you're
willing to change how you think.

I'm amazed at the speed with which Rails went from having side effects
for GET to being totally based on RESTful resources. But heavily-used
libraries change very slowly, and often it's easier to write a new
library. This happened with Python HTTP clients: we have urllib,
urllib2, and now Joe Gregorio's httplib2. I think it will also happen
with web service frameworks.

This was kind of rambling but I hope it answered your question. By the
way, you kind of switched PUT and POST. PUT is for updating resources,
and for creating brand new resources. POST is for spawning a new
resource from an existing one.

Leonard
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!