Bruce Tate on Ruby and REST
Gernot Starke points to this article by Bruce Tate. Nice try, unfortunately including some misleading statements:
Rather than inventing an exhaustive list of standards, REST uses existing Internet standards, including HTTP, XML, and TCP/IP.
Maybe true for a RESTful application, but not for REST itself.
REST clients use the same HTTP commands as your browser to access resources.
Except for PUT and DELETE.
The HTTP commands map to CRUD like this:
- Create: HTTP put
- Read: HTTP get
- Update: HTTP post
- Delete: HTTP delete
The analogy isn’t very good, anyway, but if it’s used, PUT should map to update and POST to create.
But anyway, not bad, and good to see REST get most exposure.
I just want to point out that there seems to be no consensus whether PUT or POST should be used for creating resources. After reading the HTTP 1.1 RFC I came to the conclusion that POST is for updating and PUT for creating new resources.
I disagree. The spec says “The PUT method requests that the enclosed entity be stored under the supplied Request-URI. “, which means that you need a URI to store something (and will later be able to retrieve its representation from the same URI). To me, this implies an update.
A POST often creates a new subordinate resource, such as a new item in a forum thread, and returns a new URI; but it can also do almost anything else that is not “safe” and/or “idempotent”. As I said, the analogy isn’t very good.