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
- func GetReferer(ctx context.Context) (string, bool)
- func GetRequestID(ctx context.Context) (string, bool)
- func GetSessionID(ctx context.Context) (string, bool)
- func GetTrackingID(ctx context.Context) (string, bool)
- func SetReferer(ctx context.Context, referer string) context.Context
- func SetRequestID(ctx context.Context, requestID string) context.Context
- func SetSessionID(ctx context.Context, sessionID string) context.Context
- func SetTrackingID(ctx context.Context, trackingID string) context.Context
Constants ¶
const ContextKeyReferer contextKey = "referer"
ContextKeyReferer is the context key under which the referer is stored.
const ContextKeyRequestID contextKey = "requestId"
ContextKeyRequestID is the context key under which the request ID is stored.
const ContextKeySessionID contextKey = "sessionId"
ContextKeySessionID is the context key under which the session ID is stored.
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
GetReferer returns the referer stored in ctx by SetReferer. It reports false if no referer is present.
func GetRequestID ¶
GetRequestID returns the request ID stored in ctx by SetRequestID. It reports false if no request ID is present.
func GetSessionID ¶
GetSessionID returns the session ID stored in ctx by SetSessionID. It reports false if no session ID is present.
func GetTrackingID ¶
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
SetReferer returns a copy of ctx carrying referer as the referer.
func SetRequestID ¶
SetRequestID returns a copy of ctx carrying requestID as the request ID.
func SetSessionID ¶
SetSessionID returns a copy of ctx carrying sessionID as the session ID.
Types ¶
This section is empty.