Documentation
¶
Overview ¶
package dnsctx helps with setting and getting data from the context of the current query. See the Match function source for what types are currently supported. When adding something to the context there is no check done on the type to not slow down the handler.
Index ¶
- Constants
- func Addr(ctx context.Context, key string) netip.Addr
- func Funcs(ctx context.Context, m *dns.Msg) *dns.Msg
- func Id(ctx context.Context) slog.Attr
- func Key(handler Keyer, key string) string
- func Match(ctx context.Context, key string, values []any) bool
- func Status(ctx context.Context, handler string) bool
- func String(ctx context.Context, key string) string
- func Valid(key string) bool
- func Value(ctx context.Context, key string) any
- func WithFunc(ctx context.Context, handler Keyer, f Func) context.Context
- func WithValue(ctx context.Context, key string, value any) context.Context
- type Func
- type Keyer
Constants ¶
const KeyStatus = "status"
Predefined context keys.
Variables ¶
This section is empty.
Functions ¶
func Funcs ¶
Funcs iterates over all functions that are set in the context over the message. The possibly modified message is returned.
func Id ¶ added in v0.6.6
Id returns a slog.Attr that either is empty or contains the request id as added by the id handler.
func Match ¶ added in v0.5.27
Match checks the value under key and see if it matches any of the elements in the list. This function handles strings, string slices, ints, flaot64s, net.IPs and bools. A nil value for key returns true.
func Status ¶ added in v0.5.33
Status returns boolean indicating if handler/status is set. If not found false is returned.