utils

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2023 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Exists

func Exists(name string) bool

func GetPageItems

func GetPageItems[T any](items []T, max, page int) []T

func In

func In[T comparable](items []T, item T) bool

func Index

func Index[T comparable](items []T, item T) int

func RandBytes

func RandBytes(n int) []byte

func RandString

func RandString(n int) string

func ReadYaml

func ReadYaml(file string, module any) error

func WriteYaml

func WriteYaml(file string, module any) error

Types

type UpgraderConf

type UpgraderConf func(*websocket.Upgrader)

func WithSubprotocols

func WithSubprotocols(Subprotocols []string) UpgraderConf

type WebSocket

type WebSocket struct {
	Heartbeat time.Duration
}

func DefaultWebSocket

func DefaultWebSocket() *WebSocket

func NewWebSocketServer

func NewWebSocketServer(conf ...WebSocketConfig) *WebSocket

func (*WebSocket) NewWebSocketClient

func (ws *WebSocket) NewWebSocketClient(w http.ResponseWriter, r *http.Request, responseHeader http.Header, conf ...UpgraderConf) (*websocket.Conn, error)

func (*WebSocket) Server

func (ws *WebSocket) Server(w http.ResponseWriter, r *http.Request, Subprotocols []string, handler func(c *websocket.Conn) error) error

type WebSocketConfig

type WebSocketConfig func(*WebSocket)

func WithHeartbeatInterval

func WithHeartbeatInterval(d time.Duration) WebSocketConfig

Jump to

Keyboard shortcuts

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