common

package
v30.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2026 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// WebSocket configuration values used across handlers
	WriteWait = 10 * time.Second
)

Variables

This section is empty.

Functions

func CloseWithMessage

func CloseWithMessage(conn *websocket.Conn, code int, message string) error

CloseWithMessage closes the WebSocket connection with a specific close code and message

func GetUpgrader

func GetUpgrader(allowedOrigins []string) *websocket.Upgrader

GetUpgrader returns a websocket upgrader with configurable CORS

Types

type ConnectionParams

type ConnectionParams struct {
	Writer   http.ResponseWriter
	Request  *http.Request
	Resolved *types.ResolvedStream
	Fetch    func(context.Context) (proto.Message, error)
}

ConnectionParams contains parameters for establishing a WebSocket connection

type Handler

type Handler struct {
	Logger         log.Logger
	Registry       *types.SubscriptionRegistry
	AppContextDone <-chan struct{}
	Upgrader       *websocket.Upgrader
}

Handler contains the shared state required to service WebSocket connections

func (*Handler) ServeConnection

func (h *Handler) ServeConnection(params ConnectionParams) (retErr error)

ServeConnection handles the standard WebSocket connection lifecycle

type RouteDefinition

type RouteDefinition struct {
	Pattern string
	Handler RouteHandler
}

RouteDefinition defines a WebSocket route with its pattern and handler.

func BuildWSRoutes

func BuildWSRoutes(
	handler *Handler,
	registry *encoding.DynamicRegistry,
	invoker *types.RouterInvoker,
	logger log.Logger,
) []RouteDefinition

BuildWSRoutes produces websocket routes based on the OpenAPI specification.

type RouteHandler

type RouteHandler func(http.ResponseWriter, *http.Request)

RouteHandler defines a function that handles a specific route.

Jump to

Keyboard shortcuts

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