Note that there are some explanatory texts on larger screens.

plurals
  1. POreturning absolute vs relative URIs in REST API
    primarykey
    data
    text
    <p>suppose the DogManagementPro program is an application written in client/server architecture, where the customers who buys it is supposed to run the server on his own PC, and access it either locally or remotely.</p> <p>suppose I want to support a "list all dogs" operations in the DogManagementPro REST API.</p> <p>so a GET to <code>http://localhost/DogManagerPro/api/dogs</code> should fetch the following response now:</p> <pre><code>&lt;dogs&gt; &lt;dog&gt;http://localhost/DogManagerPro/api/dogs/ralf&lt;/dog&gt; &lt;dog&gt;http://localhost/DogManagerPro/api/dogs/sparky&lt;/dog&gt; &lt;/dogs&gt; </code></pre> <p>where I want to access it remotely on my local LAN, [the local IP of my machine is 192.168.0.33] what should a a GET to <code>http://192.168.0.33:1234/DogManagerPro/api/dogs</code> fetch?</p> <p>should it be:</p> <pre><code>&lt;dogs&gt; &lt;dog&gt;http://localhost/DogManagerPro/api/dogs/ralf&lt;/dog&gt; &lt;dog&gt;http://localhost/DogManagerPro/api/dogs/sparky&lt;/dog&gt; &lt;/dogs&gt; </code></pre> <p>or perhaps:</p> <pre><code>&lt;dogs&gt; &lt;dog&gt;http://192.168.0.33/DogManagerPro/api/dogs/ralf&lt;/dog&gt; &lt;dog&gt;http://192.168.0.33/DogManagerPro/api/dogs/sparky&lt;/dog&gt; &lt;/dogs&gt; </code></pre> <p>?</p> <p>some people argue that I should subside the problem altogether by returning just a path element like so:</p> <pre><code>&lt;dogs&gt; &lt;dog&gt;/DogManagerPro/api/dogs/ralf&lt;/dog&gt; &lt;dog&gt;/DogManagerPro/api/dogs/sparky&lt;/dog&gt; &lt;/dogs&gt; </code></pre> <p>what is the best way?</p>
    singulars
    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.
 

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