package mongodbAPI import "context" type contextKey int const key contextKey = 0 // NewContext function will take an initialized *mongoAPI.Client, and store // the value in the http context for later retrieval. func NewContext(ctx context.Context, db *Client) context.Context { return context.WithValue(ctx, key, db) } // FromContext function will pull the *mongoAPI.Client from the // Go context. func FromContext(ctx context.Context) *Client { return ctx.Value(key).(*Client) }