contextx

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2026 License: MIT Imports: 1 Imported by: 1 module, 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 contextx carries request-scoped correlation values through context.Context using unexported key types so they cannot collide with keys from other packages.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetAPIVersion

func GetAPIVersion(ctx context.Context) string

GetAPIVersion returns the API version, or "" when absent.

func GetIPAddress

func GetIPAddress(ctx context.Context) string

GetIPAddress returns the client IP address, or "" when absent.

func GetRequestID

func GetRequestID(ctx context.Context) string

GetRequestID returns the request ID, or "" when absent.

func GetSessionID

func GetSessionID(ctx context.Context) string

GetSessionID returns the session ID, or "" when absent.

func GetUserAgent

func GetUserAgent(ctx context.Context) string

GetUserAgent returns the user agent, or "" when absent.

func GetUserID

func GetUserID(ctx context.Context) any

GetUserID returns the user ID, or nil when absent.

func GetUserRole

func GetUserRole(ctx context.Context) string

GetUserRole returns the user role, or "" when absent.

func WithAPIVersion

func WithAPIVersion(ctx context.Context, v string) context.Context

WithAPIVersion returns a copy of ctx carrying the API version.

func WithIPAddress

func WithIPAddress(ctx context.Context, ip string) context.Context

WithIPAddress returns a copy of ctx carrying the client IP address.

func WithRequestID

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

WithRequestID returns a copy of ctx carrying the request ID.

func WithSessionID

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

WithSessionID returns a copy of ctx carrying the session ID.

func WithUserAgent

func WithUserAgent(ctx context.Context, ua string) context.Context

WithUserAgent returns a copy of ctx carrying the user agent.

func WithUserID

func WithUserID(ctx context.Context, id any) context.Context

WithUserID returns a copy of ctx carrying the user ID. The value stays untyped because identifiers differ per deployment (string, int, uuid).

func WithUserRole

func WithUserRole(ctx context.Context, role string) context.Context

WithUserRole returns a copy of ctx carrying the user role.

Types

This section is empty.

Jump to

Keyboard shortcuts

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