package client import "context" type Client struct { config *Configuration token *Token } type contextKeyType string var contextKey contextKeyType = "client" type accessTokenRequest struct { GrantType string `json:"grant_type"` ClientId string `json:"client_id"` ClientSecret string `json:"client_secret"` } func NewClient(config *Configuration) *Client { client := &Client{ config: config, } token, err := getToken(client.config) if err != nil { return nil } client.token = token return client } func FromContext(ctx context.Context) *Client { client := ctx.Value(contextKey) if client == nil { return nil } if c, ok := client.(*Client); ok { return c } return nil } func NewWithContext(ctx context.Context) context.Context { client := ctx.Value(contextKey) if client == nil { return ctx } if c, ok := client.(*Client); ok { return context.WithValue(ctx, contextKey, c) } return ctx }