I have many resources like product, bookings and etc. Need routes to get all resources by user.
For example:
{GET} /bookings/user
I think this is incorrect, because this route would return user resource. Or I am wrong?
What is the right way?
I have many resources like product, bookings and etc. Need routes to get all resources by user.
For example:
{GET} /bookings/user
I think this is incorrect, because this route would return user resource. Or I am wrong?
What is the right way?
Copyright © 2021 Jogjafile Inc.
It returns a representation of the resource identified by
/bookings/user. What resource is that? It's up to the origin server.rest doesn't care what spelling conventions you use for your identifiers. As far as REST is concerned,
/6414b60b-1ecb-4e28-8887-4bfe120810e7is a perfectly satisfactory resource identifier.If you want human readable identifiers, that's OK too. RFC 3986 encourages that practice:
You should also keep in mind that RFC 3986 distinguishes hierarchical and non-hierarchical signal in the URI
In short, if you are describing information that is described in a hierarchy, then using path segments makes a lot of sense
That sounds like you are describing a spelling like
/my/bookings.A heuristic that may help in URI design is to consider the benefits of relative references; much as with a file system, you can use dot-segments to navigate toward the root of the namespace.
There are reasons where you might not want to support hackable URI; so you'll want to think about that constraint, and its implications, carefully.