Examples
banshee/examples-collection/examples/protocols/
http-get-json
Example: http.get and json.read; the state a health page declares.
by banshee1 installation1 version
Published on October 27, 2026. First version in this collection.
Protocol: http.get and JSON
http.get sends a GET and returns array('status' => …, 'headers' => …, 'body' => …, 'time' => …): the code, the headers, the body as a text, the time in milliseconds. Here, a health page that answers {"status": "ok"}.
How to read it
need('protocol:http')is required by everyhttp.getandhttp.post: it brings the TLS profile, the fingerprint and the User-Agent set in the tree. The address, itself, is written in the call.- A code 500 or 404 is an answer, read in
status; the collector decides what it means, herefail('critical', …). A redirection is not followed: a3xxcomes back as it is. json.readturns a JSON text into arrays: an object into keys, a list into 0, 1, 2… A text that is not JSON stops the collector, unreachable.list.get($health, 'status', 'missing'): the key, or'missing'when the page does not hold it.
To adapt it
- A deeper key:
$health['checks']['database'], orlist.getat each level when it may be missing. json.writedoes the other way, arrays into a JSON text (seeexamples/protocols/http-post).