News for hackers. Stuff that matters.
Re:Hypermedia Clients by Tomte on Thursday February 02, 2023 @12:20AM (#34622418)
> Fielding style REST with hypermedia only makes sense for the HTML web where you have a human determining how to navigate from one page to another.

That's the point I've never understood, and maybe someone here can clear it up for me?

As far as I understand, Fielding is constantly hammering on the point that navigation between resources should be hypertext-driven, so no "extraneous" information (where some resource or method is located) should be used. Only hypertext-style links from query/response to query/response.

But HTTP has very generic verbs. GET, PUT etc. They don't mean much.

Okay, REST proponents will say, while Fielding did his work in the context of HTTP, but envisioned a much richer hypertext capability.

Good. Now I have verbs like "Resize photo" or "Follow user" or "Get GPS coordinates from EXIF" in my hypertext API? How is a generic client supposed to understand those?

That's where I'm stuck. What's the use of it all if the client still needs to know everything about the domain (unavoidably, IMO)? Showing responses to the user and having him decide cannot be a real proposal, can it?

Re:Hypermedia Clients by yawaramin on Thursday February 02, 2023 @12:40AM (#34622548)

    {
      "response": {
        "actions": {
          "resizePhoto": {
            "method": "PATCH",
            "uri": "/photos/1",
            "body": {
              "w": "100",
              "h": "50"
            }
          }...
Re:Hypermedia Clients by Tomte on Thursday February 02, 2023 @12:43AM (#34622568)
Yes, that's the easy part. How does a client without extraneous information know that the action resizePhoto corresponds to the action that the user requested when dragging the image border inwards? The idea was a totally agnostic client, IIRC.

You either tightly couple the client to the API or you need AI, don't you?

And if the client needs to know that connection, how is that superior to having it do the PATCH dierectly?

Re:Hypermedia Clients by hermanradtke on Thursday February 02, 2023 @06:43AM (#34625265)
The same way a web browser knows how or interpret html. The client is written against the spec. The API drives the behavior, just like html does.

This is great in theory, but very hard to do in practice.

Re:Hypermedia Clients by pdhborges on Thursday February 02, 2023 @08:31AM (#34626233)
More examples: the browser can display pictures because there is a media type for them, same for sounds and videos.
Re:Hypermedia Clients by habitue on Thursday February 02, 2023 @10:50AM (#34628225)
So, the way I've usually seen it implemented is that you use a custom media type like `application/vnd.github.commit.json` and then your client is supposed to have some knowledge of the media types it understands.

Now that doesn't solve everything, because now you need to know relationship information too. Let's say a link on a mortgage application is `application/vnd.property.address`. Is this the property being purchased, or is this a property in the borrower's address history? The api needs to put an attribute of some kind on the links themselves to explain to a machine what they mean in context.

Humans surfing the web don't need this, they use their brains to understand from context what the link relationship is. And when they get to the new page, they don't need to have a hyper specific format for the exact page shape in order to be able to navigate the page. So while hypermedia is genius for the web, it forces an API developer to do all this insane busywork to make it so a "generic client" (which actually has a bunch of hard coded media types and link types in it) can navigate the API.

There's a reason this never took off