Skip to content

Suggestion to avoid distinction between retrieving a rel via _embedded or _links #34

Description

@eterps

Consider this example where a GET request to https://example.org/blog-post at one point in time responded with (situation A):

{
"_links": {
"self": { "href": "https://example.org/blog-post" },
"author": { "href": "https://example.org/people/alan-watts" }
},
"_embedded": {
"author": {
"_links": {
"self": { "href": "https://example.org/people/alan-watts" }
},
"name": "Alan Watts",
"born": "January 6, 1915",
"died": "November 16, 1973"
}
}
}

And some while later (or earlier) with (situation B):

{
"_links": {
"self": { "href": "https://example.org/blog-post" },
"author": { "href": "https://example.org/people/alan-watts" }
}
}

If you consider the Hypertext cache pattern, you could see the embedding as an optional optimization, and your client code shouldn't have to check whether a "rel" is embedded or not for every possible resource.

So for example Resource("https://example.org/blog-post").author.name is the same for both situation A and B (but in situation B it would result in an extra request being done).

See also https://github.com/gamache/hyperresource as a (Ruby) example of one way this distinction can be avoided in client code.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions