This recipe describes how to take a snapshot of the
resource before each update. When a client updates a resource via the
PUT, the server updates the current state of the resource,
leaving no way for the client to know what existed before the update.
However, there are cases when clients expect to be able to go back in
time and browse through the history of changes.
For example, imagine that you are designing a web service to provide past and present snapshots of traffic conditions at certain intersections. Most clients would like to see the latest conditions, but some clients may want to browse through past traffic conditions.
Alternatively consider a wiki. For each page on the wiki, the server needs to maintain a revision stack of current and past revisions for each page so that any client can retrieve, compare, and evaluate changes made to any given page.
You want to know how to keep snapshots of a resource so that clients can browse through previous versions of the resource.
Every time a client submits a
PUT request to update
a resource, before updating the resource, implicitly create a snapshot
(a copy resource). In the representation of the updated resource,
include a link to the snapshot. Also include a link in the snapshot
resource to the updated resource.
When a client submits a
DELETE request, delete the
resource along with all the snapshots.
In essence, this recipe lets you build a simple versioning mechanism ...