diff --git a/internal/thoth/context.go b/internal/thoth/context.go new file mode 100644 index 00000000..f58d5506 --- /dev/null +++ b/internal/thoth/context.go @@ -0,0 +1,14 @@ +package thoth + +import "context" + +type ctxKey struct{} + +func With(ctx context.Context, cli *Client) context.Context { + return context.WithValue(ctx, ctxKey{}, cli) +} + +func FromContext(ctx context.Context) (*Client, bool) { + cli, ok := ctx.Value(ctxKey{}).(*Client) + return cli, ok +}