While designing an API which will have a resource and a deep resource (/resource/{id}/deepResource), Is it a good design to have the deepResource as a parameter in resource path when there are numerous dynamic deepResources?
For example: A post request to create a new resource under a section of main resource
POST: /accounts/{id}/{section}
{section} can be any deep resource under account like "comment", "service request", "checkbook request" etc.
The idea is {section} can grow as the application grows. So instead of having multiple endpoints for each deep resource like /accounts/{id}/comment
/accounts/{id}/service
/accounts/{id}/checks
how about having /accounts/{id}/{section}?
Logic on the backend is handled accordingly for each deep resource that gets added in future.
Appreciate your insights.
Aucun commentaire:
Enregistrer un commentaire