ExtractUserID gets the user ID from the context.
(ctx context.Context)
| 43 | |
| 44 | // ExtractUserID gets the user ID from the context. |
| 45 | func 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. |
| 54 | func InjectUserID(ctx context.Context, userID string) context.Context { |
no outgoing calls
no test coverage detected