samedi 10 mars 2018

REST routing long paths

When reading about good practices of REST routing design I found some articles stating that if an element is a sub-resource then I should include both resources in the address e.g.

PATCH/cars/{carId}/engine/{engineId}

It looks pretty, but what if I use GUID as primary keys (ID's)? Should I follow this rules even if I have 5+ level deep relationship?

PATCH /manufacturer/{manId}/car/{carId}/engine/{engineId}/valve/{valveId}/screw/{screwId}

With GUIDS my request may look like that:

PATCH /manufacturer/00000000-0000-0000-0000-000000000000/car/00000000-0000-0000-0000-000000000000/engine/00000000-0000-0000-0000-000000000000/valve/00000000-0000-0000-0000-000000000000/screw/00000000-0000-0000-0000-000000000000

What if I end in 10 level deep relationship with filters at the end. Should I follow this pattern or are there any other good practices that would save me from this kind of URLs?

Aucun commentaire:

Enregistrer un commentaire