在RESTFul API中,恢复/回滚操作的正确http动词是什么?

Tiv*_*vie 3 rest

想象一下这样一个简单的文档管理webservice:

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
Run Code Online (Sandbox Code Playgroud)

现在,假设我想将文档回滚到先前的任意修订版本(例如,从版本5到3).

从RESTful的角度来看,什么ROUTE和什么VERB应该用于这种操作?我应该为回滚操作创建一个新动词吗?

请记住,在回滚操作中不会删除任何内容.在内部,服务器只识别不同的版本号作为最新版本号.

Ped*_*eck 6

既然你为每个版本的表示可用,回滚操作应该是幂等,最直接的方法是简单地做一个PUTdocument/[id]与内容GET document/[id]/revision/[revisionid],为revisionid你想document/[id]设置为.