3
想象strutured這樣一個簡單的文件管理Web服務:在RESTFul API中,恢復/回滾操作的正確http動詞是什麼?
document/
GET -> retrieves all documents
POST -> creates a new document
document/[id]
GET -> retrieves the "latest" revision of document specified by ID
POST -> creates a new revision of the document
document/[id]/revision
GET -> retrieves all revisions of the document
POST -> Alias to POST->document/[id]
document/[id]/revision/[revisionID]
GET -> retrieves the specified revision of the document
現在,讓我們說,我想回滾一個文件到以前的任意版本(例如,從版本5比3)。
在視REST風格來看,什麼ROUTE和應該使用什麼動詞對於這種操作的?我應該爲回滾操作創建一個新的動詞嗎?
請記住,在回滾操作中不會刪除任何內容。在內部,服務器只是識別最新的不同版本號。
從RESTful的角度來看,路由並不重要,方法取決於操作是否是冪等的。試圖回滾到與當前版本相同的版本應該什麼也不做或返回一個錯誤? –
@PedroWerneck不應該做任何事情 – Tivie