sse

package module
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2025 License: MIT Imports: 9 Imported by: 2

README

sse + ws + http

# SSE
curl -H 'Accept: text/event-stream' -N http://127.0.0.1:8080
firefox ws://localhost:8080

# WebSocket
websocat ws://[::1]:8080
websocat ws://localhost:8080

# HTTP
curl http://127.0.0.1:8080/once

# SSE over HTTP/3.
# Needs ufo, see https://github.com/btwiuse/ufo/blob/main/sse/sse.go
curl3 -H "Accept: text/event-stream" -N https://4.ufo.k0s.io:302 --http3 -H "Host: 4.ufo.k0s.io"

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitCid added in v0.0.2

func InitCid(cid int) gmx.Mutation[State]

func RemoveCid added in v0.0.2

func RemoveCid(cid int) gmx.Mutation[State]

Types

type Clients added in v0.0.2

type Clients = map[int]chan struct{}

type SSE

type SSE struct {
	Data               string
	StateMutex         *gmx.RwMx[State]
	MaxMessageInterval time.Duration
	// contains filtered or unexported fields
}

func NewSSE

func NewSSE() *SSE

func (*SSE) Clients

func (s *SSE) Clients() Clients

func (*SSE) ServeHTTP

func (s *SSE) ServeHTTP(w http.ResponseWriter, r *http.Request)

func (*SSE) SetData

func (s *SSE) SetData(data string)

type State added in v0.0.2

type State struct {
	Clients map[int]chan struct{}
}

Directories

Path Synopsis
cmd
demo command

Jump to

Keyboard shortcuts

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