sse

package
v0.29.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 2, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ForEachDataLine

func ForEachDataLine(ctx context.Context, r io.Reader, fn func(Event) bool) error

ForEachDataLine scans an SSE stream and invokes fn for each data line.

It supports both plain `data: ...` streams and named events using `event: ...` followed by `data: ...`.

Context cancellation is honoured during blocking reads: if ctx is cancelled while waiting for the next line, ForEachDataLine returns ctx.Err() promptly.

Types

type Event

type Event struct {
	Name string
	Data string
}

Event represents one SSE payload with its optional event name.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL