それはすべて依存します。まず、URI、リソース、および表現についてもっと話し、オブジェクトについて心配する必要はありません。
POST メソッドは、べき等でないリクエスト、または副作用のあるリクエスト用に設計されていますが、べき等のリクエストにも使用できます。
/some_collection/ へのフォーム データの POST 時
normalize the natural key of your data (Eg. "lowercase" the Title field for a blog post)
calculate a suitable hash value (Eg. simplest case is your normalized field value)
lookup resource by hash value
if none then
generate a server identity, create resource
Respond => "201 Created", "Location": "/some_collection/<new_id>"
if found but no updates should be carried out due to app logic
Respond => 302 Found/Moved Temporarily or 303 See Other
(client will need to GET that resource which might include fields required for updates, like version_numbers)
if found but updates may occur
Respond => 307 Moved Temporarily, Location: /some_collection/<id>
(like a 302, but the client should use original http method and might do automatically)
適切なハッシュ関数は、いくつかの連結されたフィールドと同じくらい単純かもしれません。または、大きなフィールドまたは値の場合は、切り捨てられた md5 関数を使用できます。詳細については、[ハッシュ関数] を参照してください2。
私はあなたを仮定しました:
- ハッシュ値とは異なる ID 値が必要
- ID に使用されるデータ フィールドは変更できません