web

package
v0.8.0-beta.8 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2024 License: Apache-2.0 Imports: 31 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

Variables

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)

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)

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