web

package
v0.11.0-beta.3 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2025 License: Apache-2.0 Imports: 31 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

Variables

View Source
var GlobalLock = &sync.Mutex{}
View Source
var RouteToConnMap = map[string]string{} // routeid => connid
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 []byte, 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 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