Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Middleware ¶
Middleware creates middleware that sets a dereferenced pointer value on the socket/connection-level context. The pointer is dereferenced when the first message is processed, so updates to the pointed-to value after that won't be reflected. The value persists for the lifetime of the WebSocket connection and is thread-safe.
Use this when you have a pointer to a value that you want to store by value at the connection level.
Example:
config := &ServerConfig{Timeout: 30}
router.Use(socketsetvalue.Middleware("config", config)) // Stores *config (dereferenced)
router.Bind("/process", func(ctx *velaros.Context) {
cfg := ctx.MustGetFromSocket("config").(ServerConfig) // Gets the value, not pointer
// ...
})
Note: The value is dereferenced on first message, not at middleware creation time.
See also: socketset.Middleware for direct values, socketsetfn.Middleware for dynamic values.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.