Rest 将删除请求发送到集合终结点 如何考虑以下API: /posts: /{post-id}: /likes: description: Collection of 'likes' that can be allocated to a post get: description: Get likes for a post is: [traits.pageable] post: description: Add a like to a post delete: description: Unlike a post (with queryParameter identifying the user)

Rest 将删除请求发送到集合终结点 如何考虑以下API: /posts: /{post-id}: /likes: description: Collection of 'likes' that can be allocated to a post get: description: Get likes for a post is: [traits.pageable] post: description: Add a like to a post delete: description: Unlike a post (with queryParameter identifying the user),rest,Rest,请注意,delete请求被发送到集合(而不是单个实体)。 我认为没有必要以以下形式提供单一的类似资源: /posts: /{post-id}: /likes/{like-id} => DELETE 使用像Mongodb这样的数据库,likes也可能没有id 就最后一行而言,RESTAPI的后台dbms应该与api的交互方式无关。也不相关,但我不认为这是一个真正的nodejs或java问题,因为它只是询问REST最佳实践。@CollinD我同意,删除了这些标记。也同意你其余

请注意,
delete
请求被发送到集合(而不是单个实体)。
我认为没有必要以以下形式提供单一的类似资源:

/posts: 
  /{post-id}: 
    /likes/{like-id} => DELETE

使用像Mongodb这样的数据库,likes也可能没有id

就最后一行而言,RESTAPI的后台dbms应该与api的交互方式无关。也不相关,但我不认为这是一个真正的nodejs或java问题,因为它只是询问REST最佳实践。@CollinD我同意,删除了这些标记。也同意你其余的评论。