Let's say we have two kinds of resources, user
and group
.
Every user can belong to multiple groups and each group can have many members.
Thus I can model my API like this
/
|_ /users/{id}
| |_ groups
|
|_ /groups/{id}
|_ members
Let's say our resources exposes only two actions. You could either add a user to a group or remove one from it.
When it comes to the implementation I could think of two possible requests for each action.
You could PUT a new user
in a group
's members
collection, or PUT a new group
in a user
's groups
collection.
Should I implement both "entry points"? Is this expected in RESTful applications? If not, which one should I implement?