Tim Bray and Ken MacLeod disagree (Tim's view, Ken's view) on how to define a HTTP for posting, updating, and deleting blog entries. The two approaches are to use GET and POST to do everything on one resource, or to use GET, PUT and DELETE on individual entry resources. They are both horribly wrong. The correct approach is this:
- GET on feed resource
- GETs the feed
- PUT on feed resource
- Replaces the entire feed with a new feed representation
- DELETE on feed resource
- Deletes the feed
- POST on feed resource
- Creates a new entry, and returns its URI in the Location header
- GET on entry resource
- GETs the entry
- PUT on entry resource
- Replaces the entry with a new entry representation
- DELETE on entry resource
- Deletes the entry
- POST on entry resource
- Creates a new comment, and returns its URI in the Location header
- GET on comment resource
- GETs the comment
- PUT on comment resource
- Replaces the comment with a new comment representation
- DELETE on comment resource
- Deletes the comment
- POST on comment resource
- Creates a new sub-comment, and returns its URI in the Location header
Do you see the pattern? Everything you operate on directly gets a URI. That thing can be replaced by PUTting its new value. It can DELETEd using the obvious method. You can GET it. If it is a container for children it supports the POST of a new child. You don't confuse PUT and POST, and everyone is happy.
I don't know what Tim thinks is clear and obvious, and I don't know what Ken thinks is REST, but isn't this both?
In fairness to both parties their original blog entries both date back to 2003. The reason this has come across my desk is a "REST"-tagged del.icio.us link to this intertwingly.net poll.
Benjamin