Hi Everybody,
I am sure this must have been answered well somewhere before, but I can't seem to find an answer that satisfies me...
I have a collection of 'fights', and a collection of 'fighters'. I want to be able to add and remove fighter to a fight restfully. Hence my resources and URI's are like so:
/fights/ -> all the fights that exist
/fights/{fightId} -> gives me fight fightId
The usual CRUD ops work on these resources as expected, like POST to /fights/ generates a new fight, etc.
Similarly,
/fighters/
/fighters/{fighterId}
does the same for fighters.
Now, it makes sense to me that a GET on the following should list all fighters scheduled for fightId:
/fights/{fightId}/fighters/
But what would be the advised way to add and remove fighters to/from a fight? To add should I POST to this URI with the id of an already existing fighter in the query string? Would I do a DELETE to /fights/{fightId}/fighters/{fighterId} to remove that fighter?
Maybe I am being picky, I don't know. My concern is that if I were to follow this approach then there is some inconsistency in DELETE's to /fighters/{fighterId} vs /fights/{fightId}/fighters/{fighterId}. One actually deletes an object from the DB whereas the other deletes an association, not the actual object it is talking about. However, the different URI's do establish the context of the operations, which maybe acceptable.
How rigid should these things be, or should I breakdown and make and add, remove verbs hanging off the end like this:
/fight/{fightId}/add?category=fight&id=fighterId
which seems complicated and yucky.
I hope I am clear-ish. Thank you in advance,
Aaron