I’m writing a web API server that serves three relevant types of resources: authors, groups and channels. Each channel must be owned by exactly one author or group, and access control is determined by the requesting user’s relationship to the author or group in question, so I planned on creating a URL structure like:
- GET /authors/{authorId} — view specific author
- POST /authors/{authorId}/channels — create a channel belonging to that author
- GET /authors/{authorId}/channels — list channels belonging to that author
- GET /authors/{authorId}/channels/{channelId} — view specific channel belonging to that author
- GET /groups/{groupId} — view specific group
- POST /groups/{groupId}/channels — create a channel belonging to that group
- GET /groups/{groupId}/channels — list channels belonging to that group
- GET /groups/{groupId}/channels/{channelId} — view specific channel belonging to that group
The finished server will have many more paths for dealing with authors, groups and channels; these are given as examples.
Is it reasonable to attempt to do this with three controllers (i.e. AuthorsController, GroupsController, ChannelsController) in Spring Web MVC? How would I wire them together with RequestMapping annotations? Is there a way to decompose these responsibilities that makes more sense in Spring Web MVC, but still preserves cohesion?
N.B. I have seen a similar question asked, but the question and answers all focused on the inner classes.