Skip to content

Instantly share code, notes, and snippets.

@zdennis
Last active August 29, 2015 14:06
Show Gist options
  • Save zdennis/5d2244bb4790d646e744 to your computer and use it in GitHub Desktop.
Save zdennis/5d2244bb4790d646e744 to your computer and use it in GitHub Desktop.
HAL curies for docs, separating curie URL templates from link relation descriptions. The differences below are due to the way that WebLinking RFC 5988 has specified that non-registered relations must be URLs
"_links": {
"curies": [
{
"name": "doc",
"href": "http://haltalk.herokuapp.com/docs/{rel}",
"templated": true
}
],
// this is the "latest-posts" link relation. The base documentation URL can change
// without breaking clients that are looking for 'latest-posts'
"doc:latest-posts": {
"href": "/posts/latest"
}
}
{
"class": [ "order" ],
"properties": {
"orderNumber": 42,
"itemCount": 3,
"status": "pending"
},
"entities": [
{
"class": [ "items", "collection" ],
// NOTE THE URL
"rel": [ "http://x.io/rels/order-items" ],
"href": "http://api.x.io/orders/42/items"
},
{
"class": [ "info", "customer" ],
"rel": [ "http://x.io/rels/customer" ],
"properties": {
"customerId": "pj123",
"name": "Peter Joseph"
},
"links": [
{ "rel": [ "self" ], "href": "http://api.x.io/customers/pj123" }
]
}
],
"actions": [
{
"name": "add-item",
"title": "Add Item",
"method": "POST",
"href": "http://api.x.io/orders/42/items",
"type": "application/x-www-form-urlencoded",
"fields": [
{ "name": "orderNumber", "type": "hidden", "value": "42" },
{ "name": "productCode", "type": "text" },
{ "name": "quantity", "type": "number" }
]
}
],
"links": [
// NOTE THE LACK OF URL
{ "rel": [ "self" ], "href": "http://api.x.io/orders/42" },
{ "rel": [ "previous" ], "href": "http://api.x.io/orders/41" },
{ "rel": [ "next" ], "href": "http://api.x.io/orders/43" }
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment