From 5d510915d2793c018b0b4b6daadeaa91a230f622 Mon Sep 17 00:00:00 2001 From: Eli Ribble Date: Mon, 20 Apr 2026 22:42:21 +0000 Subject: [PATCH] Add version to frontend connection --- api/event.go | 8 +++++++- main.go | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/api/event.go b/api/event.go index 1744ea05..374dd5f6 100644 --- a/api/event.go +++ b/api/event.go @@ -61,6 +61,12 @@ func SetEventChannel(chan_envelopes <-chan platform.Envelope) { } }() } + +var version string = "unknown" + +func SetVersion(v string) { + version = v +} func send[T any](w http.ResponseWriter, msg T) error { jsonData, err := json.Marshal(msg) if err != nil { @@ -96,7 +102,7 @@ func streamEvents(w http.ResponseWriter, r *http.Request, u platform.User) { log.Debug().Int32("org", u.Organization.ID).Int("user", u.ID).Str("id", uid.String()).Msg("connected SSE client") // Send an initial connected event - fmt.Fprintf(w, "event: connected\ndata: {\"status\": \"connected\", \"time\": \"%s\"}\n\n", time.Now().Format(time.RFC3339)) + fmt.Fprintf(w, "event: connected\ndata: {\"status\": \"connected\", \"version\": \"%s\", \"time\": \"%s\"}\n\n", version, time.Now().Format(time.RFC3339)) w.(http.Flusher).Flush() // Keep the connection open with a ticker sending periodic events diff --git a/main.go b/main.go index 6d7bc2da..ed7a67bf 100644 --- a/main.go +++ b/main.go @@ -157,6 +157,7 @@ func main() { }() chan_envelope := make(chan platform.Envelope, 10) + api.SetVersion(Version) platform.SetEventChannel(chan_envelope) api.SetEventChannel(chan_envelope)