Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <blockquote> <p>I can't help but think something is wrong...</p> </blockquote> <p>The only thing you're doing wrong is thinking that your URI structure makes your application more or less RESTful. The <a href="http://www.ics.uci.edu/~fielding/pubs/dissertation/top.htm" rel="nofollow noreferrer">original REST literature</a> never says that query strings are bad. People tend to get hung up on URI structure and seem to think that your URIs must be structured a certain way to be considered RESTful. There is nothing wrong with using <code>?username=&lt;username&gt;</code>. <strong>A URI is just an ID</strong> <em>(though some can be more human friendly than others)</em>.</p> <p>Bottom line: don't get hung up on how your URIs <strong>look</strong>. There are much more important things to focus on (promoting hyperlinking/hypermedia, sticking to a uniform interface - typically HTTP, cacheability, etc.).</p> <p>This may be a big of a digression but, as for your comment about the coupling of resources to models, you're still okay. If you do go the /reports/ID/user route, just think of 'user' as a relationship name on your reports model. Surely your model defines the relationship between a report and a user. You can just parse the last part of your URI so that it matches the name of this relationship. In the case of one to one relationship like you describe its always a good idea to also set the <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.14" rel="nofollow noreferrer">Content-Location</a> header to match the canonical URI of the user. </p> <p>For example. Say report 123 belongs to user 1. You now have two ways of referring this user:</p> <pre><code>http://example.com/reports/123/user http://example.com/user/1 </code></pre> <p>For the first URI, it would also be a good idea to set <code>Content-Location: http://example.com/user/1</code> header</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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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