Documentation
¶
Overview ¶
Package ctx provides typed context value helpers for passing per-request data (buffer, logger, metadata, recorder objects) through the handler chain.
Index ¶
- func BufferFromContext(ctx context.Context) *bytes.Buffer
- func ContextWithBuffer(ctx context.Context, buffer *bytes.Buffer) context.Context
- func ContextWithLogger(ctx context.Context, log logger.Logger) context.Context
- func ContextWithMetadata(ctx context.Context, md metadata.Metadata) context.Context
- func ContextWithRecorderObject(ctx context.Context, ro *xrecorder.HandlerRecorderObject) context.Context
- func ContextWithSession(ctx context.Context, s *xrecorder.Session) context.Context
- func ContextWithUDPBindDevice(ctx context.Context) context.Context
- func LoggerFromContext(ctx context.Context) logger.Logger
- func MetadataFromContext(ctx context.Context) metadata.Metadata
- func RecorderObjectFromContext(ctx context.Context) *xrecorder.HandlerRecorderObject
- func SessionFromContext(ctx context.Context) *xrecorder.Session
- func UDPBindDeviceFromContext(ctx context.Context) bool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BufferFromContext ¶
BufferFromContext returns the *bytes.Buffer stored in ctx, or nil.
func ContextWithBuffer ¶
ContextWithBuffer returns a copy of ctx with the given buffer stored. The buffer is used by dialers and connectors to reuse a *bytes.Buffer for protocol handshake data (e.g. TLS ClientHello, HTTP requests).
func ContextWithLogger ¶
ContextWithLogger returns a copy of ctx with the given logger stored.
func ContextWithMetadata ¶
ContextWithMetadata returns a copy of ctx with the given metadata stored.
func ContextWithRecorderObject ¶
func ContextWithRecorderObject(ctx context.Context, ro *xrecorder.HandlerRecorderObject) context.Context
ContextWithRecorderObject returns a copy of ctx with the given recorder object stored.
func ContextWithSession ¶ added in v0.28.1
func ContextWithUDPBindDevice ¶ added in v0.28.1
ContextWithUDPBindDevice marks an empty-address UDP relay dial as requiring an operating-system device bind in addition to its local-address bind.
func LoggerFromContext ¶
LoggerFromContext returns the logger stored in ctx, or nil.
func MetadataFromContext ¶
MetadataFromContext returns the metadata stored in ctx, or nil.
func RecorderObjectFromContext ¶
func RecorderObjectFromContext(ctx context.Context) *xrecorder.HandlerRecorderObject
RecorderObjectFromContext returns the recorder object stored in ctx, or nil.
func SessionFromContext ¶ added in v0.28.1
func UDPBindDeviceFromContext ¶ added in v0.28.1
UDPBindDeviceFromContext reports whether the UDP relay dial explicitly requested an operating-system device bind.
Types ¶
This section is empty.