REST junction/mix of resource retrieving. Which controller use?

The problem is not easy to explain in english as I'm not.

Well this is simple I try to do a REST api and I could have these URI:

  • get /events/10/users/2
  • get /users/2/events/10

As you can see I can retrieve an user which is register inside an event and I can retrieve an event which is linked to a user. It's just an exemple.

My problem now is how to implement with good logic ? Which controller to use ? User or Event controller ?

Because of REST I have this mix of ressource and for sure something like /users?id=2&event=10 and /events?id=10&user=2 is more easy to understand and I know where to retrieve the user and the event.

Neither of these routes are really necessary or recommended for a clean REST API. What you should have is:

get /events/10/users   <-- Get list of all users for event #10
get /users/2/events    <-- Get list of all events for user #2
get /events/10         <-- Get all info about event #10
get /users/2           <-- Get all info about user #2

There's no reason to access a user record via the events API, or vice versa--they should be accessed through their own APIs.