Saturday, 15 August 2015

RESTful uri: /rest/course/module/prblem/solution vs /rest/solution -



RESTful uri: /rest/course/module/prblem/solution vs /rest/solution -

i designing restful interface hierarchical data:

course > module > problem > solution

but cannot decide url accessing "solution" resource should be. these 2 options choosing between, example, retrieve solution globally unique pk=3:

/courses/2/modules/5/problems/2/solutions/3 /solutions/3/

any advice on of 2 preferable?

whenever have come urls inquire myself (in context)

can solution resource exist without problem, module or course?

yes -> /solutions/3

no -> /courses/2/modules/5/problems/2/solutions/3

if solution needs problem exist, i.e. belongs problem, makes little sense utilize short url.

another way lok @ it: on backend, need reference problem in order able fetch solution?

no -> /solutions/3

yes -> /courses/2/modules/5/problems/2/solutions/3

rest django-rest-framework backend

No comments:

Post a Comment