Repository navigation
Home
The standard GSON view extension to support HAL responses designed to work nice with Domain objects, but not with Map. Also it requires to put all elements of the HAL structure (for example "self" inside "_links" which required by HAL standard). Missing them results in invalid HAL document.
In addition to that it is impossible to debug GSON view (with or without HAL extension).
This plug-in solves all these problems.
HALM plug-in defines the DSL to create HAL view from any objects and allows to include regular Groovy code in the view. For debugging purpose developer can copy the content of the view inside the Controller and debug it as regular code. After code work as expected move code back to the view and it should continue working.
Also the HALM code doesn't look like the HAL document it makes creation of the valid HAL document more easy:
- automatically creating self link (absolute or relative to the servlet) using the actual URL of the request
- all links/templates/embeddeds combined at the top of the JSON regardless of the order of the elements in the code
- multiple links/templates/embeddeds with the same relation automatically combined into collection of such objects
- special convention for the URLs allows automatically use whatever servlet base URL to append relative path or leave it relative
According to standard the simplest HAL document must include element "_links" inside it -- element "self" with at least element "href" in it. The view creating such document is:
hal { }
It will result in follow document (nice printed):
{
"_links": {
"self": {
"href": <complete_URL_from_the_request>,
"type": "application/hal+json"
}
}
}
Plugin provides multiple ways to define content of the HAL document. For details please check specific pages.
For structure of the view definition check Structure of the HAL view page.