gotify - push notifications to a Gotify server
Import with import "gotify.j" as gotify;. A tiny module on top of the
http client that pushes a notification to a
Gotify server. Hold a value-semantic Config (server URL
- application token) and call
push. Because it builds onhttp(which usesnet), this module needs the defaultjenniferbinary.
On
jennifer-tiny: “needs the defaultjenniferbinary” refers to the stock tiny build, which ships without a network driver - not a TinyGo limitation. Ajennifer-tinyrebuilt with a network stack runs this module too; see the note onnetand TinyGo.
import "gotify.j" as gotify;
import "http.j" as http;
def g as gotify.Config init gotify.Config{url: "https://push.example.com",
token: "AqB3cD..."};
def r as http.Response init gotify.push($g, "Deploy", "build 1234 is live", 5);
io.printf("pushed -> %d\n", $r.status); # 200 on success
Runnable: examples/modules/gotify_demo.j.
Surface
| Call / type | Notes |
|---|---|
gotify.Config | url (server, no trailing slash) and token (application key). |
gotify.push(cfg, title, message, priority) | POST the message; returns the http.Response. |
push POSTs title / message / priority as
application/x-www-form-urlencoded to cfg.url + "/message" with an
X-Gotify-Key: cfg.token header - Gotify’s
push-message contract, where
priority is a plain int (0 lowest, higher is
more urgent). It returns the raw http.Response, so the caller checks
.status: a 200 on success, and a bad token comes back as a 4xx value,
not a crash.
Stateless by design
There is no init() that stashes the URL and token - a module has no mutable
state. The caller holds the value-semantic Config and passes it to each
push, the same shape as the time / hash structs. The URL and token are
yours to supply and never commit: read them from the environment or a config
file. The demo reads GOTIFY_URL / GOTIFY_TOKEN from the environment; the docs
use placeholders.
See also
- http.md - the client
gotifyposts through. - modules/index.md - the module catalog and import rules.