title: Design a REST resource to manage a list
body: <p>Let's say I want to design a REST store used to manage a list.
  A list entry would look something like this:</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;listentry&gt;
      &lt;position&gt;0&lt;/position&gt;                &lt;!-- position in the list --&gt;
      &lt;data&gt;interesting information&lt;/data&gt;  &lt;!-- entry data --&gt;
  &lt;/listentry&gt;
  </code></pre>
  
  <p>I would design the resource like this:</p>
  
  <pre class="lang-js prettyprint-override"><code>GET    /list/           // returns all list entries
  GET    /list/{position} // returns the list entry at {position}
  DELETE /list/{position} // delete list entry at {position}
  
  PUT    /list/first      // update first list entry
  PUT    /list/last       // update last list entry
  PUT    /list/{position} // update entry at {position}
  
  POST   /list/last       // inserts a new list entry at last position
  POST   /list/first      // inserts a new list entry at first position
  
  POST   /list/{position} // inserts a new list entry at {position} and moves all 
                          // entries down  the list starting from the entry that
                          // was at {position} before the insertion.
  </code></pre>
  
  <p>is this a legal REST resource? If not is there a way to design a rest resource so that it can manage a list?</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>Thank you for the input it definetly helped.
  I agree with nategood and darrel that the use of first and last as special identifiers is perfectly legal (see also my <a href="https://stackoverflow.com/questions/9380833/is-creating-rest-subresources-to-get-the-last-or-first-element-of-a-list-bad-pra" title="post">question</a> on this). Of course I could do without those magic identifiers as suggested by Saintedlama, but this would rob me of the possibillity to use them in the post requests I want to present you now.</p>
  
  <p>While thinking again about the design, I would like to add two additional functionalities to my resource design suggestion.</p>
  
  <pre class="lang-js prettyprint-override"><code>POST   /list/{position1}/swap/{position2}   // swap the position of two elements
  POST   /list/{position1}/move/{position2}   // move the element at {position1} to
                                              // {position2} and move all entries 
                                              // down the list starting from the 
                                              // entry that was at {position2}
  
  //possible uses
  POST   /list/first/swap/last                // swap first with last element
  POST   /list/42/swap/2                      // swap element 42 with element 2
  POST   /list/first/move/42                  // move first element to position 42
  // you get the idea ...
  </code></pre>
  
  <p>What do you think?</p>