リストの管理に使用する REST ストアを設計したいとします。リスト エントリは次のようになります。
<listentry>
<position>0</position> <!-- position in the list -->
<data>interesting information</data> <!-- entry data -->
</listentry>
次のようにリソースを設計します。
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.
これは合法的な REST リソースですか? そうでない場合、リストを管理できるように残りのリソースを設計する方法はありますか?
編集
間違いなく役立つ情報をありがとうございます。first と last を特別な識別子として使用することは完全に合法であるという nategood と darrel に同意します (これに関する私の質問も参照してください)。もちろん、Saintdlama によって提案されているように、これらの魔法の識別子なしで行うこともできますが、これを行うと、今提示したい投稿リクエストでそれらを使用する可能性が失われます。
設計を再考しながら、リソース設計の提案に 2 つの機能を追加したいと考えています。
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 ...
どう思いますか?