21 lines
465 B
Go
21 lines
465 B
Go
package api
|
|
|
|
import "context"
|
|
|
|
type contextKey string
|
|
|
|
const tokenInfoKey contextKey = "tokenInfo"
|
|
|
|
// withTokenInfo stores token info in context.
|
|
func withTokenInfo(ctx context.Context, info *TokenInfo) context.Context {
|
|
return context.WithValue(ctx, tokenInfoKey, info)
|
|
}
|
|
|
|
// GetTokenInfo retrieves token info from context.
|
|
func GetTokenInfo(ctx context.Context) *TokenInfo {
|
|
if v := ctx.Value(tokenInfoKey); v != nil {
|
|
return v.(*TokenInfo)
|
|
}
|
|
return nil
|
|
}
|