util

package
v0.0.0-...-83154c6 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2025 License: ISC Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ErrorAndAbort

func ErrorAndAbort(w http.ResponseWriter, r *http.Request, status int, key string, errs ...error)

func ErrorAndDisconnect

func ErrorAndDisconnect(ctx context.Context, conn *websocket.Conn, err error)

func ErrorWithCode

func ErrorWithCode(err error, code string) error

func GenerateLobbyCode

func GenerateLobbyCode(ctx context.Context) string

func GeneratePeerID

func GeneratePeerID(ctx context.Context) string

func GenerateSecret

func GenerateSecret(ctx context.Context) string

func GenerateShortLobbyCode

func GenerateShortLobbyCode(ctx context.Context, chars int) string

GenerateShortLobbyCode generates a short lobby code with the given number of characters. The code is generated using al alpabet of characters that are easy to distinguish from each other (e.g. no 0 and O).

func Getenv

func Getenv(key, def string) string

func IsUUID

func IsUUID(in string) bool

func NoStoreMiddleware

func NoStoreMiddleware(next http.Handler) http.Handler

func NowUTC

func NowUTC(ctx context.Context) time.Time

func RenderJSON

func RenderJSON(w http.ResponseWriter, r *http.Request, status int, val any)

RenderJSON will write a json response to the given ResponseWriter.

func ReplyError

func ReplyError(ctx context.Context, conn *websocket.Conn, err error)

func ShouldIgnoreNetworkError

func ShouldIgnoreNetworkError(err error) bool

func WithRequestID

func WithRequestID(ctx context.Context, id string) context.Context

WithRequestID returns a new context with the given request ID attached, this ID can be used when replying errors etc.

Types

This section is empty.

Jump to

Keyboard shortcuts

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