web

package
v0.14.0-beta.2 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2026 License: Apache-2.0 Imports: 35 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CacheControlHeaderKey     = "Cache-Control"
	CacheControlHeaderNoCache = "no-cache"

	ContentTypeHeaderKey = "Content-Type"
	ContentTypeJson      = "application/json"
	ContentTypeBinary    = "application/octet-stream"

	ContentLengthHeaderKey = "Content-Length"
	LastModifiedHeaderKey  = "Last-Modified"

	WaveZoneFileInfoHeaderKey = "X-ZoneFileInfo"
)

Header constants

View Source
const DefaultCommandTimeout = 2 * time.Second
View Source
const HttpMaxHeaderBytes = 60000
View Source
const HttpReadTimeout = 5 * time.Second
View Source
const HttpTimeoutDuration = 21 * time.Second
View Source
const HttpWriteTimeout = 21 * time.Second
View Source
const TransparentGif64 = "R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7"
View Source
const WSStatePacketChSize = 20
View Source
const WSStateReconnectTime = 30 * time.Second
View Source
const WebSocketChannelSize = 128

Variables

View Source
var GlobalLock = &sync.Mutex{}
View Source
var RouteToConnMap = map[string]*StableConnInfo{} // stableid => StableConnInfo
View Source
var WebSocketUpgrader = websocket.Upgrader{
	ReadBufferSize:   4 * 1024,
	WriteBufferSize:  32 * 1024,
	HandshakeTimeout: 1 * time.Second,
	CheckOrigin:      func(r *http.Request) bool { return true },
}

Functions

func HandleWs

func HandleWs(w http.ResponseWriter, r *http.Request)

func HandleWsInternal

func HandleWsInternal(w http.ResponseWriter, r *http.Request) error

func MakeTCPListener

func MakeTCPListener(serviceName string) (net.Listener, error)

func MakeUnixListener

func MakeUnixListener() (net.Listener, error)

func ReadLoop

func ReadLoop(conn *websocket.Conn, outputCh chan any, closeCh chan any, rpcInputCh chan baseds.RpcInputChType, routeId string)

func RunWebServer

func RunWebServer(listener net.Listener)

blocking

func RunWebSocketServer

func RunWebSocketServer(listener net.Listener)

func WriteJsonError

func WriteJsonError(w http.ResponseWriter, errVal error)

func WriteJsonSuccess

func WriteJsonSuccess(w http.ResponseWriter, data interface{})

func WriteLoop

func WriteLoop(conn *websocket.Conn, outputCh chan any, closeCh chan any, routeId string)

func WritePing

func WritePing(conn *websocket.Conn) error

Types

type ClientActiveState

type ClientActiveState struct {
	Fg     bool `json:"fg"`
	Active bool `json:"active"`
	Open   bool `json:"open"`
}

type StableConnInfo added in v0.14.0

type StableConnInfo struct {
	ConnId string
	LinkId baseds.LinkId
}

type WebFnOpts

type WebFnOpts struct {
	AllowCaching bool
	JsonErrors   bool
}

type WebFnType

type WebFnType = func(http.ResponseWriter, *http.Request)

func WebFnWrap

func WebFnWrap(opts WebFnOpts, fn WebFnType) WebFnType

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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