From 86635c6e9c0f82f52110e32f79c595e8fa3bd988 Mon Sep 17 00:00:00 2001 From: Alexander Korelskiy Date: Wed, 21 Sep 2022 17:04:19 +0300 Subject: [PATCH] Fix X-Request-ID header generation for golang client --- golang/go_template.go | 4 ++-- golang/testdata/catalogue_client.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/golang/go_template.go b/golang/go_template.go index 861bf30..562563c 100644 --- a/golang/go_template.go +++ b/golang/go_template.go @@ -173,8 +173,8 @@ func (rc *rpcClient) Exec(ctx context.Context, rpcReq zenrpc.Request) (*zenrpc.R req.Header = rc.header.Clone() req.Header.Add("Content-Type", "application/json") - if xRequestID := ctx.Value("X-Request-ID"); xRequestID.(string) != "" { - req.Header.Add("X-Request-ID",xRequestID.(string)) + if xRequestID, ok := ctx.Value("X-Request-ID").(string); ok && xRequestID != "" { + req.Header.Add("X-Request-ID", xRequestID) } // Do request diff --git a/golang/testdata/catalogue_client.go b/golang/testdata/catalogue_client.go index 2b47b02..7ad9d0f 100755 --- a/golang/testdata/catalogue_client.go +++ b/golang/testdata/catalogue_client.go @@ -536,8 +536,8 @@ func (rc *rpcClient) Exec(ctx context.Context, rpcReq zenrpc.Request) (*zenrpc.R req.Header = rc.header.Clone() req.Header.Add("Content-Type", "application/json") - if xRequestID := ctx.Value("X-Request-ID"); xRequestID.(string) != "" { - req.Header.Add("X-Request-ID", xRequestID.(string)) + if xRequestID, ok := ctx.Value("X-Request-ID").(string); ok && xRequestID != "" { + req.Header.Add("X-Request-ID", xRequestID) } // Do request