What's the best way to represent a list resource when the list can be "owned" by different resources?
Take your typical blog example.
Say you've got Posts, Comments and Users. A Post has many Comments and a User is the author of many Comments.
You may want to get a list of Comments within the context of a given User (e.g. that User's commenting history), for a given Post (e.g. all the comments on that post) or maybe just all of the Comments, period (though this is not terribly likely).
You could have three different URIs:
/user/user_id/comments
/post/post_id/comments
/comments
Is this OK? My understanding is that URIs should be idempotent. Is it more "RESTful" to have a single url: /comments
and pass filtering parameters? e.g.
/comments?user=user_id
/comments?post=post_id
I guess this second method means you can also filter by user and post with
/comments?user=user_id&post=post_id
But I like how the first example exposes hierarchical context.
What's the best practice here?