It will be difficult for you to choose which answer is correct, most answers seem to indicate that your option 2 is the right choice :)
As far as I know, the fewer problems with the REST architecture, the better it was to take into account that each resource has only these forms that return a list (possibly filtered) or a resource:
/mainResources /mainResources/:id
And that /mainResources/:id/:relatedResources is an alias /relatedResources?mainResourceId[]=... (returns a filtered list)
Your option 2 gives you the freedom to add additional relationships such as /exceptions?country={countryCode}&anotherResource={anotherResourceId}&startTime={value}&endTime={value}
Your other options are not incompatible if you consider them to be pseudonyms.
Another reason I can think of using URLs such as /mainResource/:id/subResource would be in the case of a denormalized relation such as:
{ 'attribute1': 'value1' 'attribute2': 'value2' 'attribute3': 'value3' 'subResource': { 'attribute4': 'value4', 'attribute5': 'value5' } }
then this url could return this sub-resource:
{ 'attribute4': 'value4', 'attribute5': 'value5' }
But this is just data filtering. And, considering your case, the exclusion from the country of exceptions would be inconvenient.
arvymetal
source share