知识卡片
撤销操作需保存历史
已提交的更新或删除后来需要撤回时,接口必须提供安全恢复路径,并考虑并发修改和下游影响。
单资源更新可以再发条件PUT写回旧值,前提是保留旧值并确认资源未被他人修改。删除没有通用UNDELETE方法,可设计undoDelete或rollback动作,用原地址及版本信息恢复;服务需保留可恢复历史。若一个动作影响多个资源和下游服务,撤销还需覆盖所有影响,不可把本地回写当成完整回滚。
这张卡片看不懂?
这张卡片已通过人工审查,不再接受失败反馈。
已有反馈 · 0 条
还没有人提交反馈。
在整书笔记中的位置
原书出处 · 1 处
- 超媒体接口设计 · 查看原书依据
You might have issued an HTTP DELETE for a resource and want to recover that resource. There is no HTTP UNDELETE method. Instead you need to restore an existing record with a special command. The safest way is to create another, special operation (undoDelete) that uses HTTP PUT and some argument (usually the previous URL along with a validation value like the ETag header). This means the service interface needs to be designed to support this feature, including saving DELETEd resources in case they need to be restored!