MCPcopy Create free account
hub / github.com/Monibuca/engine / NewSSE

Function NewSSE

util/sse.go:48–59  ·  view source on GitHub ↗
(w http.ResponseWriter, ctx context.Context)

Source from the content-addressed store, hash-verified

46}
47
48func NewSSE(w http.ResponseWriter, ctx context.Context) *SSE {
49 header := w.Header()
50 header.Set("Content-Type", "text/event-stream")
51 header.Set("Cache-Control", "no-cache")
52 header.Set("Connection", "keep-alive")
53 header.Set("X-Accel-Buffering", "no")
54 header.Set("Access-Control-Allow-Origin", "*")
55 return &SSE{
56 ResponseWriter: w,
57 Context: ctx,
58 }
59}
60
61func (sse *SSE) WriteJSON(data any) error {
62 return json.NewEncoder(sse).Encode(data)

Callers 1

ReturnFetchValueFunction · 0.85

Calls 2

SetMethod · 0.80
HeaderMethod · 0.65

Tested by

no test coverage detected