Note that there are some explanatory texts on larger screens.

plurals
  1. POREST API Design links between collections of resources
    primarykey
    data
    text
    <p>I have been pondering the correct method of defining resource collections which have interdependence. </p> <p>For instance, lets consider "documents" and "comments" which are independently accessible via the URI's:</p> <pre><code>/documents/{doc-uri} /comments/{comment-id} </code></pre> <p>However, we typically want the collection of comments related to a specific document. Which creates a design question around how this should be archetected.</p> <p>I can see a few main options:</p> <p>1.) Supply an collection uri after the document uri for comments</p> <pre><code>GET /documents/{doc-uri}/comments/ </code></pre> <p>2.) Provide a parameter to the comments collection to select by document</p> <pre><code>GET /comments/{comment-id}?related-doc={doc-uri} </code></pre> <p>3.) Use content negotiation to request the related comments be returned via the Accept header.</p> <pre><code>// Get all the comments for a document GET /documents/{doc-uri} Accept: application/vnd.comments+xml // Create a new comment POST /documents/{doc-uri} Content-Type: application/vnd.comment+xml &lt;comment&gt;...&lt;/comment&gt; </code></pre> <p>Method 1 has the advantage of automatically putting the comments in context of the document. Which is also nice when creating,updating and deleting comments using POST/PUT. However it does not provide global access to comments outside the context of a document. So if we wanted to do a search over all comments in the system we would need method #2.</p> <p>Method 2 offers many of the same benefits as #1, however creating a comment without the context of a document makes no sense. Since comments must explicitly be related to a document.</p> <p>Method 3 is interesting from a GET and POST/create perspective, but gets kinda hairy with update and delete. </p> <p>I can see pro's and con's to all these methods so I am looking for some more guidance from someone who may have approached and solved this issue before.</p> <p>I am considering doing both methods 1 &amp; 2, thus I can provide all the functionality needed, but I am concerned I may be over-complicating/duplicating functionality.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload