【发布时间】:2013-09-18 19:56:07
【问题描述】:
我有一个对象:
Account
{
Id,
Name,
CurrentBalance
}
Id 是不可变键,Name 是可变字符串,CurrentBalance 是根据与帐户关联的所有交易计算得出的。
我坚持GET \Accounts\{Id} 不会是幂等的,因为对事务的更改会导致CurrentBalance 的更改。我是否应该从对象中删除此字段并发出类似的请求
POST \Accounts\{Id}\CurrentBalance
但现在我必须多次调用服务器才能获取所有对象的CurrentBalance:
GET \Accounts
POST \Accounts\{Id1}\CurrentBalance
POST \Accounts\{Id2}\CurrentBalance
POST \Accounts\{Id3}\CurrentBalance
....
我想我只是想看看是否已经有一个标准的方法来处理我所缺少的?
更新
如果原始对象通过 GET 正常,则为第 2 部分。我更新 Account.Name 的唯一方法是通过 PATCH,因为我不允许更新 CurrentBalance,对吗?
注意
我意识到我可以将它放在客户端上以获取所有交易并计算它,但出于多种原因我更愿意在服务器上执行此操作
【问题讨论】:
标签: http rest httpverbs idempotent