6 ms·
I tend to find it helpful to ask, "is this proper REST as in HATEOAS, or is just 'REST-ish'?" It's usually just REST-ish: predefined URL patterns, roughly 1:1 w
by fennecfoxen 4y ago
I tend to find it helpful to ask, "is this proper REST as in HATEOAS, or is just 'REST-ish'?" It's usually just REST-ish: predefined URL patterns, roughly 1:1 with specific resource-APIs; they care about your HTTP verb and return JSON (but usually not with a lot of URLs in that JSON).
- kelseyfrog 4y agoIt's funny because HATEOAS violations were single-handedly the most common violation made by the client team during my time there. They loved hard coding URLs and willfully ignoring hypermedia.
- sanderjd 4y agoSee, to me, this sounds like a failure to listen to your customer. They were telling you that well known URLs were useful to them, and you were forcing them to make more compromises so that you could make fewer.
- kelseyfrog 4y agoWe answered to the architecture team on matters of design. If the client team had had beef with the design, the client team took it up with them.
- quickthrower2 4y agoWhat do they do if they don’t hard code it? bookHotelUri = listHotelResponse.data.urls[4]; Or listHotelResponse .data.urls.find(u=>u.action===‘book’).url ?
- kelseyfrog 4y agoSort of. Verbs are still eschewed so rather than finding a 'book' link, it would be a 'booking' link to which a POST could be made to create a new booking. As a note, "Booking" is a confusing example because while a hotel booking is a noun it at first glance reads as a progressive tense verb.
- jasonboyd 4y agoSo instead of a hard coded url it's a hard coded reference to a url? How does it deal with a breaking changing? Say the order of the links changes? It doesn't seem like this works without some out of band information.
- kelseyfrog 4y agoThey are keyed using rels. You're right, they aren't relying on order; that would be terrible. And yes, JSON doesn't "have" rels. This is worked around by specifying a mimetype which does. Is it turtles all the way down? Yes, but not all turtles are equivalent. You should already be specifying a "Content-Type": application/json, it's not too much to change that to application/vnd.api+json and write a spec somewhere.
- kelseyfrog 4y agolistHotelResponse.data.urls.find(u=>u.rel===‘booking’).url Web linking is defined in https://www.rfc-editor.org/rfc/rfc8288.html https://www.rfc-editor.org/rfc/rfc8288.html and that's the basis for using rel as well as a host of other attributes.