MCPcopy
hub / github.com/grafana/dskit / ExtractUserID

Function ExtractUserID

user/id.go:45–51  ·  view source on GitHub ↗

ExtractUserID gets the user ID from the context.

(ctx context.Context)

Source from the content-addressed store, hash-verified

43
44// ExtractUserID gets the user ID from the context.
45func ExtractUserID(ctx context.Context) (string, error) {
46 userID, ok := ctx.Value(userIDContextKey).(string)
47 if !ok {
48 return "", ErrNoUserID
49 }
50 return userID, nil
51}
52
53// InjectUserID returns a derived context containing the user ID.
54func InjectUserID(ctx context.Context, userID string) context.Context {

Callers 3

CollectedRequestFunction · 0.92
LogWithFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected