Repository navigation
Different forms of URLs
In all places where HAL expects a URL it can be specified in a few different ways:
- if String starts with '
/' (or '{/' for templates) the URL assumed to be relative - if String starts with any other character it assumed to be absolute
Relative URL will be prepended by the base servlet URL before include in the resulting HAL document.
Also if the first element of the path after servlet is "/api" it is also included into base URL. This allows to reuse the same implementation for both Web requests (without "/api") and API requests (with "/api"). The same code will create HAL with appropriate links (no "/api" for Web request and with "/api" for API requests).
On the top level if empty String passed to "hal '' {...}" function than URL for that element will be extracted from the requested URL by removing base servlet URL (without "/api" part). This makes it a relative URL to the resource currently serving.
Absoute URL starts with any character but '/' (or '{/' for templates). This makes complete URL considered absolute and require no modification.
Also if HAL document should include relative URL without making it into absolute URL the String should start without '/'.
Follow examples assumes the Web application "C06A" running on the server "github.com".
Absolut URL "https://github.com/C06A/HALM/wiki" will be copied to the HAL document as is without any change.
Relative path "C06A/HALM/wiki" will be handled as absolute (it doesn't start with '/') and also will be copied as is. That URL will be interpreted by browser as relative to the domain and as such return the same resource as previous example.
Relative path "/HALM/wiki" will be prepended by the HALM with the base servlet URL (in this example "https://github.com/C06A" which make it to the same resulting URL.