context

package
v0.36.0 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 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 context provides helpers to store and retrieve request-scoped identifiers in a context.Context: the referer, request ID, session ID and tracking ID.

Middleware in github.com/foomo/keel/net/http/middleware stores the request, session and tracking IDs of incoming requests, and round-trippers in github.com/foomo/keel/net/http/roundtripware forward these values on outgoing requests.

Index

Constants

View Source
const ContextKeyReferer contextKey = "referer"

ContextKeyReferer is the context key under which the referer is stored.

View Source
const ContextKeyRequestID contextKey = "requestId"

ContextKeyRequestID is the context key under which the request ID is stored.

View Source
const ContextKeySessionID contextKey = "sessionId"

ContextKeySessionID is the context key under which the session ID is stored.

View Source
const ContextKeyTrackingID contextKey = "trackingId"

ContextKeyTrackingID is the context key under which the tracking ID is stored.

Variables

This section is empty.

Functions

func GetReferer added in v0.14.3

func GetReferer(ctx context.Context) (string, bool)

GetReferer returns the referer stored in ctx by SetReferer. It reports false if no referer is present.

func GetRequestID

func GetRequestID(ctx context.Context) (string, bool)

GetRequestID returns the request ID stored in ctx by SetRequestID. It reports false if no request ID is present.

func GetSessionID

func GetSessionID(ctx context.Context) (string, bool)

GetSessionID returns the session ID stored in ctx by SetSessionID. It reports false if no session ID is present.

func GetTrackingID

func GetTrackingID(ctx context.Context) (string, bool)

GetTrackingID returns the tracking ID stored in ctx by SetTrackingID. It reports false if no tracking ID is present.

func SetReferer added in v0.14.3

func SetReferer(ctx context.Context, referer string) context.Context

SetReferer returns a copy of ctx carrying referer as the referer.

func SetRequestID

func SetRequestID(ctx context.Context, requestID string) context.Context

SetRequestID returns a copy of ctx carrying requestID as the request ID.

func SetSessionID

func SetSessionID(ctx context.Context, sessionID string) context.Context

SetSessionID returns a copy of ctx carrying sessionID as the session ID.

func SetTrackingID

func SetTrackingID(ctx context.Context, trackingID string) context.Context

SetTrackingID returns a copy of ctx carrying trackingID as the tracking ID.

Types

This section is empty.

Jump to

Keyboard shortcuts

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