set

package
v1.21.0 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Middleware

func Middleware[V any](key string, value V) func(ctx *velaros.Context)

Middleware creates middleware that sets a value on the message-level context. The value is set once when the middleware is created and reused for all messages. Values set at the message level only exist for the duration of that message's handler chain.

Use this when you want to share a constant value across handlers for each message.

Example:

router.Use(set.Middleware("apiVersion", "v1"))

router.Bind("/info", func(ctx *velaros.Context) {
    version := ctx.MustGet("apiVersion").(string)  // "v1"
    ctx.Send(map[string]string{"version": version})
})

See also: setfn.Middleware for dynamic values, setvalue.Middleware for pointer values.

Types

This section is empty.

Jump to

Keyboard shortcuts

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