mode

package
v0.3.3 Latest Latest
Warning

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

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

Documentation

Overview

Package mode selects the wire protocol between server and browser. Pass one of the constants to [tether.StatefulConfig].Mode.

tether.StatefulConfig[State]{
    Mode: mode.Both,
    // ...
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Transport

type Transport int

Transport selects the wire protocol between server and browser. WebSocket gives bidirectional communication over a single connection. ServerSentEvents splits the channel: server→client updates flow over a long-lived EventSource stream, and client→server events arrive as individual HTTP POSTs. Both tries WebSocket first and falls back to SSE+POST automatically. HTTP is plain request/response with no persistent connection, used by [tether.Stateless].

const (
	// HTTP uses plain request/response - no persistent connection.
	// Client events are sent as individual POST requests and the
	// response carries the update. Used internally by [tether.Stateless].
	HTTP Transport = iota + 1

	// WebSocket accepts only WebSocket connections. The Fallback
	// field is ignored; Upgrade must be set.
	WebSocket

	// ServerSentEvents accepts only SSE+POST connections. Use this
	// when the deployment environment does not support WebSocket
	// (e.g. certain PaaS providers or corporate proxies). The
	// Upgrade field is ignored; Fallback must be set.
	ServerSentEvents

	// Both tries WebSocket first. If the client cannot establish a
	// WebSocket connection (e.g. the proxy strips the Upgrade
	// header), it falls back to SSE+POST automatically. Both
	// Upgrade and Fallback must be set.
	Both
)

Jump to

Keyboard shortcuts

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