fctx

package
v0.13.1 Latest Latest
Warning

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

Go to latest
Published: May 29, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func From

func From(ec echo.Context) context.Context

From returns the request-scoped context.Context from an echo.Context.

Call this once at the handler boundary; downstream code should accept context.Context, not echo.Context.

func Logger

func Logger(ctx context.Context) *zap.Logger

Logger returns the request-scoped *zap.Logger from ctx. Returns a no-op logger if none was registered.

func Middleware

func Middleware(logger *zap.Logger, tracer trace.Tracer) echo.MiddlewareFunc

Middleware injects logger, tracer, and request ID into the request's context.Context, making them available via Logger, Tracer, and RequestID.

tracer may be nil (tracing disabled). Tracer returns a no-op fallback.

func MustLogger

func MustLogger(ctx context.Context) *zap.Logger

MustLogger returns the request-scoped *zap.Logger from ctx. Panics if no logger is present. Use in code that must fail fast when context is misconfigured.

func RequestID

func RequestID(ctx context.Context) string

RequestID returns the request ID from ctx. Returns "" if no request ID is present.

func Tracer

func Tracer(ctx context.Context) trace.Tracer

Tracer returns the OTel tracer from ctx. Returns a no-op tracer if none was registered, no spans are produced.

func WithLogger

func WithLogger(ctx context.Context, l *zap.Logger) context.Context

WithLogger stores the logger in ctx.

func WithRequestID

func WithRequestID(ctx context.Context, id string) context.Context

WithRequestID stores the request ID in ctx.

func WithTracer

func WithTracer(ctx context.Context, t trace.Tracer) context.Context

WithTracer stores the tracer in ctx.

Types

This section is empty.

Jump to

Keyboard shortcuts

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