Hypertext Application Language: Difference between revisions

Content deleted Content added
some general purpose example on HAL
Tags: nowiki added Visual edit
Line 7:
== Convention ==
HAL is structured in such a way as to represent elements based on two concepts: Resources and Links. Resources consist of [[URI]] links, embedded resources, your standard data (be it JSON or XML), and non URI links. Links have a target URI, as well as the name of the link (referred to as 'rel'), as well as optional properties designed to be mindful of depreciation and content negotiation.<ref name="stateless"/>
 
==Example==
General Resource { "_links": { "self": { "href": "<nowiki>http://example.com/api/book/hal-cookbook</nowiki>" } }, "id": "hal-cookbook", "name": "HAL Cookbook" }
 
Embedded resource { "_links": {"self": {"href": "<nowiki>http://example.com/api/book/hal-cookbook</nowiki>"}}, "_embedded": { "author": { "_links": {"self": {"href": "<nowiki>http://author-example.com</nowiki>"}}, "id": "shahadat", "name": "Shahadat Hossain Khan" } } "id": "hal-cookbook", "name": "HAL Cookbook" }
 
Collections { "_links": { "self": {"href": "<nowiki>http://example.com/api/book/hal-cookbook</nowiki>"}, "next": {"href": "<nowiki>http://example.com/api/book/hal-case-study</nowiki>"}, "prev": {"href": "<nowiki>http://example.com/api/book/json-and-beyond</nowiki>"}, "first": {"href": "<nowiki>http://example.com/api/book/catalog</nowiki>"}, "last": {"href": "<nowiki>http://example.com/api/book/upcoming-books</nowiki>"} }, "_embedded": { "author": { "_links": {"self": {"href": "<nowiki>http://author-example.com</nowiki>"}}, "id": "shahadat", "name": "Shahadat Hossain Khan" } } "id": "hal-cookbook", "name": "HAL Cookbook" }
 
==See also==