Open aslakknutsen opened 8 years ago
Optimistic locking semantics are already built into the HTTP protocol.
Return ETag header on GET
Request:
GET /api/workitems/12
Response
200 Content-Type: application/json ETag: "0" { "fields": {...}}
Update object with correct v
PUT /api/workitems/12 If-Match: "0" { "fields": {...}}
200 Content-Type: application/json ETag: "1" { "fields": {...}}
Update object with wrong v
412 Precondition Failed Content-Type: application/json
Only get body if ETag has changed
GET /api/workitems/12 If-Non-Match: "0"
Don't return body if ETag match
GET /api/workitems/12 If-Non-Match: "1"
304 Content-Type: application/json
I have edited the description to use workitems in the URL end points.
workitems
Optimistic locking semantics are already built into the HTTP protocol.
Return ETag header on GET
Request:
Response
Update object with correct v
Request:
Response
Update object with wrong v
Request:
Response
Only get body if ETag has changed
Request:
Response
Don't return body if ETag match
Request:
Response