Container Pattern

Table of contents
No headers

The container pattern builds on the entity pattern by providing the means to dynamically add and/or update nested resources.  For example, in the case of our blog resource, we could not reliably determine the name of the blog post resource, because of race conditions.  In this case, we need to use a POST operation to add the nested resource.

POST http://myserver/myblog

A contents of the POST request must contain enough information about the intended operation to be carried out.  For example, it might be used to add one or more nested resources.  Regardless of specifics, the POST operation can only affect the resource and its nested resources.


When a nested resource is created, the POST response should contain the location of the new resource.  Also, if the POST operation can modify the resource before creating it, it should include the updated resource in its response.


The Atom Publishing Protocol is an excellent example of applying the container pattern to create a blogging application interface.


A container resource has the following pattern:

Verb Resource Meaning
GET /resource Retrieve the entire resource.  Query parameters may be available to retrieve only parts of the resource.
PUT /resource Replace the entire resource and all nested resources.
DELETE /resource Delete the entire resource and all nested resources.
POST /resource Creates a nested resource.
GET /resource/nested (optional) Retrieve the entire nested resource.  Query parameters may be available to retrieve only parts of the nested resource.
PUT /resource/nested (optional) Replace or create the entire nested resource and all its nested resources.
DELETE /resource/nested (optional) Delete the entire nested resource and all its nested resources.
* /resource/nested (optional) Additional verbs may be supported by the nested resource.
Tag page
You must login to post a comment.
Powered by MindTouch Deki v.8.08