Documentation
¶
Index ¶
- Constants
- Variables
- func GetAllWSInfo() map[string]WSInfo
- func GetFileSystem() http.FileSystem
- func HandleWs(w http.ResponseWriter, r *http.Request)
- func HandleWsInternal(w http.ResponseWriter, r *http.Request) error
- func MakeTCPListener(serviceName string, addr string) (net.Listener, error)
- func ReadLoop(conn *websocket.Conn, outputCh chan WSEventType, closeCh chan any, ...)
- func RunWebServerWithListener(ctx context.Context, httpListener net.Listener)
- func ServeIndexOrFile(w http.ResponseWriter, r *http.Request, fs http.FileSystem)
- func WriteJsonError(w http.ResponseWriter, errVal error)
- func WriteJsonSuccess(w http.ResponseWriter, data interface{})
- func WriteLoop(conn *websocket.Conn, outputCh chan WSEventType, closeCh chan any, ...)
- func WritePing(conn *websocket.Conn) error
- type TrayAppRunInfo
- type WSEventType
- type WSInfo
- type WebFnOpts
- type WebFnType
- type WebSocketModel
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" )
Header constants
View Source
const EventType_Ping = "ping"
View Source
const EventType_Pong = "pong"
View Source
const EventType_Rpc = "rpc"
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
Variables ¶
View Source
var ConnMap = utilds.MakeSyncMap[string, *WebSocketModel]()
Functions ¶
func GetAllWSInfo ¶
GetAllWSInfo returns a map of connection ID to WSInfo for all WebSocket connections
func GetFileSystem ¶
func GetFileSystem() http.FileSystem
GetFileSystem returns the appropriate filesystem to use based on environment In development mode, it returns the local filesystem In production mode, it returns the embedded filesystem
func HandleWs ¶
func HandleWs(w http.ResponseWriter, r *http.Request)
HandleWs handles WebSocket connections This is now served through the HTTP server on the same port
func HandleWsInternal ¶
func HandleWsInternal(w http.ResponseWriter, r *http.Request) error
func RunWebServerWithListener ¶ added in v0.9.0
RunWebServerWithListener runs the HTTP server using the provided listener
func ServeIndexOrFile ¶
func ServeIndexOrFile(w http.ResponseWriter, r *http.Request, fs http.FileSystem)
ServeIndexOrFile serves either the requested file or falls back to index.html This is necessary for SPA (Single Page Application) routing
func WriteJsonError ¶
func WriteJsonError(w http.ResponseWriter, errVal error)
func WriteJsonSuccess ¶
func WriteJsonSuccess(w http.ResponseWriter, data interface{})
Types ¶
type TrayAppRunInfo ¶
type TrayAppRunInfo struct {
AppRunId string `json:"apprunid"`
AppName string `json:"appname"`
IsRunning bool `json:"isrunning"`
StartTime int64 `json:"starttime"`
}
TrayAppRunInfo contains minimal app run information for the tray app
type WSEventType ¶
type WebSocketModel ¶
type WebSocketModel struct {
ConnId string
RouteId string
Conn *websocket.Conn
OutputCh chan WSEventType
}
Click to show internal directories.
Click to hide internal directories.