3 ms·
> With REST, the URL for a resource never changes. I could have an endpoint example.com/users become example.com/subsite/users. It is precisely because the URL
by pilgrim689 14y ago
> With REST, the URL for a resource never changes.
I could have an endpoint example.com/users become example.com/subsite/users. It is precisely because the URL might change that you want to give the client URLs to the next possible actions.
- BerislavLopac 14y agoEr, but no; you're very wrong. First, yes, you could change your "endpoint" URL, but that's not the reason for providing URLs in HATEOAS (just for the record, I hate(oas) that acronym). You see, REST is different from most other Web services because it doesn't provide access to actions, but to resources. It can be compared to the good old SQL database -- and a resource's URL is the way to uniquely identify that resource, just like in a RDB you would have a combination of a table and a unique identifier. The reason for providing URLs is to free the consumer from having to construct it by hand each time. In fact, an URL can change -- but not an URL to a single resource (just like you wouldn't arbitrary change a RDB record's ID); rather, a completely different resource can be provided instead.
- pilgrim689 14y agoI misused "action". Replace "to give the client URLs to the next possible actions." with "to give the client URLs so they can perform their next possible actions on related resources". My point remains: one of the main reasons of using HATEOAS is so that you can evolve your API without breaking clients. The other main benefit is so that your client can discover your protocol by simply following hypermedia controls.