feat: frontend receiving processing images and showing them as such

This commit is contained in:
2025-05-10 17:39:09 +01:00
parent 71dfe5647e
commit a4b94fc6c2
7 changed files with 49 additions and 102 deletions

View File

@@ -3,6 +3,7 @@ package main
import (
"context"
"database/sql"
"encoding/json"
"fmt"
"net/http"
"os"
@@ -151,6 +152,7 @@ func CreateEventsHandler(notifier *Notifier[Notification]) http.HandlerFunc {
// EG: The user could attempt to create many connections
// and they just get a 500, with no explanation.
w.WriteHeader(http.StatusInternalServerError)
w.(http.Flusher).Flush()
return
}
@@ -163,8 +165,15 @@ func CreateEventsHandler(notifier *Notifier[Notification]) http.HandlerFunc {
w.(http.Flusher).Flush()
return
case msg := <-listener:
msgString, err := json.Marshal(msg)
if err != nil {
w.WriteHeader(http.StatusInternalServerError)
return
}
fmt.Printf("Sending msg %s\n", msg)
fmt.Fprintf(w, "event: data\ndata: %s\n\n", msg)
fmt.Fprintf(w, "event: data\ndata: %s\n\n", string(msgString))
w.(http.Flusher).Flush()
}
}