1

Item次の方法でリソースを公開したいと考えています。

GET /Item (to show all Items)
GET /Item/401 (to show only the Item with key value 401)

ここまでは順調ですね。ここで、自分に属するアイテムのみをリクエストするために、次の URI 構造が考えられます。

GET /Item/Mine
GET /MyItem
GET /Item/owner=42 (where my ID is 42)

最後の 1 つは好きではありません。クライアント プログラミングが単純化され、既存の認証に依存して「自分の」ID が特定されるからです。私はたまたま ASP.NET WebAPI でコーディングしていますが、実装ではなく、原則と設計について質問しています。

私の質問: 「My」アイテムを表現する 3 つの方法のうち、RESTful 設計コンセプトと最も一致しているのはどれですか? 「マイ」アイテムをそのように要求することは合法ですか?

4

2 に答える 2

1

I would use GET /Items to get all itmes.

And GET /Items?owner=42.

GET /Item/Mine is not consistent since it contradicts your way of identifying the resource ie,
GET /Item/401.

GET /MyItem seems seems unnecessary since the resources you are looking for can be retrieved using the other REST url paths.

于 2013-08-05T19:02:04.033 に答える