Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to map different UI views in a RESTful web application?
    primarykey
    data
    text
    <p>I'm designing a web application, which will support both standard UIs (accessed via browsers) and a RESTful API (an XML/JSON-based web service). User agents will be able to differentiate between these by using different values in the <code>Accept</code> HTTP header.</p> <p>The RESTful API will use the following URI structure (example for an "article" resource):</p> <ul> <li><code>GET /article/</code> - gets a list of articles</li> <li><code>POST /article/</code> - adds a new article</li> <li><code>PUT /article/{id}</code> - updates an existing article based on <code>{id}</code></li> <li><code>DELETE /article/{id}</code> - deletes an existing article based on <code>{id}</code></li> </ul> <p>The UI part of the application will however need to support multiple views, for example:</p> <ul> <li>a standard resource view</li> <li>a view for submitting a new resource</li> <li>a view for editing an existing resource</li> <li>a view for deleting an existing resource (i.e. display delete confirmation)</li> </ul> <p>Note that the latter three views are still accessed via <code>GET</code>, even though they are processed via overloaded <code>POST</code>.</p> <hr> <p><em>Possible solution:</em><br /> Introduce additional parameters (keywords) into URIs which would identify individual views - i.e. on top of the above, the application would support the following URIs (but only for <code>Content-Type: text/html</code>):</p> <ul> <li><code>GET /article/add</code> - displays a form for adding a new article (fetched via <code>GET</code>, processed via <code>POST</code>)</li> <li><code>GET /article/123</code> - displays article 123 in "view" mode (fetched via <code>GET</code>)</li> <li><code>GET /article/123/edit</code> - displays article 123 in "edit" mode (fetched via <code>GET</code>, processed via <code>PUT</code> overloaded as <code>POST</code>)</li> <li><code>GET /article/123/delete</code> - displays "delete" confirmation for article 123 (fetched via <code>GET</code>, processed via <code>DELETE</code> overloaded as <code>POST</code>)</li> </ul> <p>A better implementation of the above might be to put the add/edit/delete keywords into a GET parameter - since they do not change the resource we're working with, it might be better to keep the base URI same for all of them.</p> <hr> <p><strong>My question is:</strong><br /> How would you map the above URI structure to UIs served to the regular user, considering that there can be several views per each resource, please? Do you agree with the possible solution detailed above, or would you recommend a different approach based on your experience?</p> <p>NB: we've already implemented an application which consists of a standalone RESTful API and a standalone web application. I'm currently looking into options for future projects where these two would be merged together (i.e. in order to reduce overhead).</p>
    singulars
    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