Rest API 多对多关系的资源设计

Rest API resource design for many-to-many relation

Post 可以在许多 类别 部分 中。 Category and Section can have many Posts

要列出 sections/categories 使用:

GET /posts/categories
GET /posts/sections

似乎比以下设计更好:

GET /categories
GET /sections

但是如何从sections/categories请求Posts

有什么建议吗?

我个人会使用查询参数方法来过滤帖子集合,因为它是多对多关系并且可以独立管理资源:

GET /posts?section={id}

我可能会对类别和部分使用以下映射:

GET /categories
GET /sections

例如,如果一组帖子仅属于一个 单个 类别,我将使用:

GET /categories/{id}/posts