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 ¶
- func GetAPIVersion(ctx context.Context) string
- func GetIPAddress(ctx context.Context) string
- func GetRequestID(ctx context.Context) string
- func GetSessionID(ctx context.Context) string
- func GetUserAgent(ctx context.Context) string
- func GetUserID(ctx context.Context) any
- func GetUserRole(ctx context.Context) string
- func WithAPIVersion(ctx context.Context, v string) context.Context
- func WithIPAddress(ctx context.Context, ip string) context.Context
- func WithRequestID(ctx context.Context, id string) context.Context
- func WithSessionID(ctx context.Context, id string) context.Context
- func WithUserAgent(ctx context.Context, ua string) context.Context
- func WithUserID(ctx context.Context, id any) context.Context
- func WithUserRole(ctx context.Context, role string) context.Context
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetAPIVersion ¶
GetAPIVersion returns the API version, or "" when absent.
func GetIPAddress ¶
GetIPAddress returns the client IP address, or "" when absent.
func GetRequestID ¶
GetRequestID returns the request ID, or "" when absent.
func GetSessionID ¶
GetSessionID returns the session ID, or "" when absent.
func GetUserAgent ¶
GetUserAgent returns the user agent, or "" when absent.
func GetUserRole ¶
GetUserRole returns the user role, or "" when absent.
func WithAPIVersion ¶
WithAPIVersion returns a copy of ctx carrying the API version.
func WithIPAddress ¶
WithIPAddress returns a copy of ctx carrying the client IP address.
func WithRequestID ¶
WithRequestID returns a copy of ctx carrying the request ID.
func WithSessionID ¶
WithSessionID returns a copy of ctx carrying the session ID.
func WithUserAgent ¶
WithUserAgent returns a copy of ctx carrying the user agent.
func WithUserID ¶
WithUserID returns a copy of ctx carrying the user ID. The value stays untyped because identifiers differ per deployment (string, int, uuid).
Types ¶
This section is empty.