wsrelay

package
v1.2.10 Latest Latest
Warning

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

Go to latest
Published: May 11, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MessageTypeHTTPReq     = "http_request"
	MessageTypeHTTPResp    = "http_response"
	MessageTypeStreamStart = "stream_start"
	MessageTypeStreamChunk = "stream_chunk"
	MessageTypeStreamEnd   = "stream_end"
	MessageTypeError       = "error"
	MessageTypePing        = "ping"
	MessageTypePong        = "pong"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type HTTPRequest

type HTTPRequest struct {
	Method  string
	URL     string
	Headers http.Header
	Body    []byte
}

type HTTPResponse

type HTTPResponse struct {
	Status  int
	Headers http.Header
	Body    []byte
}

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

func NewManager

func NewManager(opts Options) *Manager

func (*Manager) Handler

func (m *Manager) Handler() http.Handler

func (*Manager) NonStream

func (m *Manager) NonStream(ctx context.Context, provider string, req *HTTPRequest) (*HTTPResponse, error)

func (*Manager) Path

func (m *Manager) Path() string

func (*Manager) Send

func (m *Manager) Send(ctx context.Context, provider string, msg Message) (<-chan Message, error)

func (*Manager) Stop

func (m *Manager) Stop(_ context.Context) error

func (*Manager) Stream

func (m *Manager) Stream(ctx context.Context, provider string, req *HTTPRequest) (<-chan StreamEvent, error)

type Message

type Message struct {
	ID      string         `json:"id"`
	Type    string         `json:"type"`
	Payload map[string]any `json:"payload,omitempty"`
}

Message represents the JSON payload exchanged with websocket clients.

type Options

type Options struct {
	Path            string
	ProviderFactory func(*http.Request) (string, error)
	OnConnected     func(string)
	OnDisconnected  func(string, error)
	LogDebugf       func(string, ...any)
	LogInfof        func(string, ...any)
	LogWarnf        func(string, ...any)
}

type StreamEvent

type StreamEvent struct {
	Type    string
	Payload []byte
	Status  int
	Headers http.Header
	Err     error
}

Jump to

Keyboard shortcuts

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