From 1c277bd97ba9751b1b0f64cfdfa5a3231a76b4b3 Mon Sep 17 00:00:00 2001 From: Roman Khimov Date: Wed, 26 May 2021 21:25:05 +0300 Subject: [PATCH] api: fix golint suggestion for proper context usage api/user-auth.go:27:5 golint should not use basic type string as key in context.WithValue Signed-off-by: Roman Khimov --- api/user-auth.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/api/user-auth.go b/api/user-auth.go index 85cab1824..cb530e7a8 100644 --- a/api/user-auth.go +++ b/api/user-auth.go @@ -9,8 +9,11 @@ import ( "go.uber.org/zap" ) +// KeyWrapper is wrapper for context keys. +type KeyWrapper string + // BearerTokenKey is an ID used to store bearer token in a context. -const BearerTokenKey = "__context_bearer_token_key" +var BearerTokenKey = KeyWrapper("__context_bearer_token_key") // AttachUserAuth adds user authentication via center to router using log for logging. func AttachUserAuth(router *mux.Router, center auth.Center, log *zap.Logger) {