From 9bb38d6ad016c1d8940cc48822bb8c56853da0b2 Mon Sep 17 00:00:00 2001 From: Xe Iaso Date: Thu, 22 May 2025 11:07:19 -0400 Subject: [PATCH] feat(thoth): store a thoth client in a context Signed-off-by: Xe Iaso --- internal/thoth/context.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 internal/thoth/context.go 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 +}