From 52968a3048835365fab399f3f9e17be40a65cfae Mon Sep 17 00:00:00 2001 From: Tanishq Porwar Date: Tue, 11 Mar 2025 02:15:49 +0530 Subject: [PATCH] add functions to get and set operationId in request context --- client_context.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 client_context.go diff --git a/client_context.go b/client_context.go new file mode 100644 index 0000000..4cffe51 --- /dev/null +++ b/client_context.go @@ -0,0 +1,18 @@ +package runtime + +import "context" + +type operationIdKey int + +const key = operationIdKey(0) + +func WithOperationId(ctx context.Context, operationId string) context.Context { + return context.WithValue(ctx, key, operationId) +} + +func GetOperationId(ctx context.Context) string { + if operationId, ok := ctx.Value(key).(string); ok { + return operationId + } + return "" +}