We are creating a REST API and we currently have two approaches for defining the resources.
Basically we have Patients
, Studies
and Images
where a Patient
has n Studies
and a Study
has n Images
.
Hierarchical Approach
/webapi/patients/0/studies/12/images
The hierarchy is visible in the URI
To search for all images we would need a search resource
/webapi/search?q=imageName:mountain
Flat Approach
/webapi/patients/0
/webapi/studies/12
/webapi/images/
The hierarchy is done by an attribute (for example study 12
has a patientId
of 0).
To search for all images we can search on the resource itself:
/webapi/images?q=imageName:mountain
Is there a best practice approach or does anyone have experienced a similar scenario? Is a search resource REST or is it bad that the relation from an image is not visible in the flat approach.
Also we need to think about move and modification.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…