这是 REST URL 的良好结构吗?
假设:
GET /account <- get list of accounts
GET /account/1234 <- get account 1234
等等
如果帐户资源有我想要接口的集合,这是个好主意吗?
GET /account/1234/note <- get notes for account 1234
POST /account/1234/note <- add note to account 1234
DELETE /account/1234/note/321 <- delete note 321 on account 1234
尤其是最后一个让我停下来;通常我在删除时不需要实体 ID 和父 ID。
或者也许这样的事情会更好?
GET /account-note/1234 <- get notes for account 1234
POST /account-note/1234 <- add note to account 1234
DELETE /account-note/321 <- delete note 321 on account 1234 (b/c note 321 is on account 1234)
但后来我会得到一个非常浅的 URL 集。
谢谢