Skip to content

Instantly share code, notes, and snippets.

@semmons99
Last active December 21, 2015 07:48
Show Gist options
  • Save semmons99/6273370 to your computer and use it in GitHub Desktop.
Save semmons99/6273370 to your computer and use it in GitHub Desktop.
{
first_name: "Shane",
last_name: "Emmons",
_links: {
"self": {"href": "/users/1"},
"disable": {"href": "/users/1/disable"}
}
}
@semmons99
Copy link
Author

I'm working on a new Hypermedia API. We've chosen hal+json for our representation and have our state machine sketched out for our initial interactions. What we're having trouble with is representing our transitions as links. In the example JSON below I want to have a link that allows a user to be disabled.

I have two questions.

  1. Should I be hanging a transition like "disable" off of a user like this?
  2. How does a client know if this link, or any link, should be a GET, POST, PATCH, DELETE?

As I write this I'm thinking perhaps the default for a client should be to try a GET on any link and in the case of disable be returned some type of templated object that is the used to POST and disable a user?

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