ctx

package
v0.28.2 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2026 License: MIT Imports: 5 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package ctx provides typed context value helpers for passing per-request data (buffer, logger, metadata, recorder objects) through the handler chain.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BufferFromContext

func BufferFromContext(ctx context.Context) *bytes.Buffer

BufferFromContext returns the *bytes.Buffer stored in ctx, or nil.

func ContextWithBuffer

func ContextWithBuffer(ctx context.Context, buffer *bytes.Buffer) context.Context

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

func ContextWithLogger(ctx context.Context, log logger.Logger) context.Context

ContextWithLogger returns a copy of ctx with the given logger stored.

func ContextWithMetadata

func ContextWithMetadata(ctx context.Context, md metadata.Metadata) context.Context

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 ContextWithSession(ctx context.Context, s *xrecorder.Session) context.Context

func ContextWithUDPBindDevice added in v0.28.1

func ContextWithUDPBindDevice(ctx context.Context) context.Context

ContextWithUDPBindDevice marks an empty-address UDP relay dial as requiring an operating-system device bind in addition to its local-address bind.

func LoggerFromContext

func LoggerFromContext(ctx context.Context) logger.Logger

LoggerFromContext returns the logger stored in ctx, or nil.

func MetadataFromContext

func MetadataFromContext(ctx context.Context) metadata.Metadata

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 SessionFromContext(ctx context.Context) *xrecorder.Session

func UDPBindDeviceFromContext added in v0.28.1

func UDPBindDeviceFromContext(ctx context.Context) bool

UDPBindDeviceFromContext reports whether the UDP relay dial explicitly requested an operating-system device bind.

Types

This section is empty.

Jump to

Keyboard shortcuts

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