From 3a118836f862e132b7b3db8904bf88011b15591c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Caner=20=C3=87=C4=B1dam?= Date: Wed, 20 Dec 2023 14:01:53 +0300 Subject: [PATCH] add utility methods to get and set bot id in context --- utils/apiutils/principal.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/utils/apiutils/principal.go b/utils/apiutils/principal.go index 819cbcaa..c5e9a367 100644 --- a/utils/apiutils/principal.go +++ b/utils/apiutils/principal.go @@ -7,6 +7,7 @@ type contextKey int const ( contextKeyPrincipalAddressValue contextKey = 1 contextKeyBatchValue contextKey = 2 + contextKeyBotID contextKey = 3 ) func GetAddress(ctx context.Context) string { @@ -24,3 +25,11 @@ func GetBatch(ctx context.Context) string { func SetBatch(ctx context.Context, batch string) context.Context { return context.WithValue(ctx, contextKeyBatchValue, batch) } + +func GetBotID(ctx context.Context) string { + return ctx.Value(contextKeyBotID).(string) +} + +func SetBotID(ctx context.Context, addr string) context.Context { + return context.WithValue(ctx, contextKeyBotID, addr) +}