sse

package
v0.40.0 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2026 License: MIT Imports: 5 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: ...`.

For closable readers, cancellation and early termination close the reader to unblock any in-flight Read and wait for the scanner goroutine to exit.

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