package controller import ( "encoding/json" "github.com/r3labs/sse/v2" "gitlab.unjx.de/flohoss/cafe-plaetschwiesle/internal/types" ) const ServerSideEvent = "sse" type StatusMessage struct { Type types.NotifierType `json:"type"` Payload []Order `json:"payload"` } func (c *Controller) setupEventChannel() { c.SSE.AutoReplay = false c.SSE.CreateStream(ServerSideEvent) } func (c *Controller) publishMessage(msg StatusMessage) { json, _ := json.Marshal(msg) c.SSE.Publish(ServerSideEvent, &sse.Event{Data: json}) }