This library provides a component, that adds an http endpoint to tesla-microservice that will produce a json-home document with links to resources of your microservice.
Because tesla-microservice is a provided dependency, you must always specify two dependencies in your project clj:
:dependencies [[de.otto/tesla-microservice "0.3.36"]
[de.otto/tesla-jsonhome "0.2.1"]]
Add the jsonhome
component to the base-system before starting it.
(assoc (system/base-system runtime-config)
:jsonhome (component/using (jsonhome/new-jsonhome "/jsonhome/") [:config :handler]))
Resources have to be added via the config of your tesla-microservice.
If you have a config like that:
jsonhome.resources.status.href=/your-status
jsonhome.resources.health.href=/your-health
jsonhome.resources.health.title=Health Check
This Json-Home document would be rendered:
{
"resources": {
"health": {
"href": "/your-health",
"title": "Health Check"
},
"status": {
"href": "/your-status"
}
}
}
It is common practice to use full-qualified names as keys in the resources hash.
To prefix every resource, you can set jsonhome.link-rel-prefix
in your config.
For Example this config:
jsonhome.link-rel-prefix=http://spec.example.com/link-rel/
will produce this Json-Home document like this:
{
"resources": {
"http://spec.example.com/link-rel/health": {
"href": "/health"
},
"http://spec.example.com/link-rel/status": {
"href": "/status"
}
}
}
Torsten Mangner, Tobias Radtke, Kai Brandes
Versions 0.1.0
and above of tesla-jsonhome are compatible with versions 0.1.15
and above of tesla-microservice.
Apache License