From eda8f737e2232aade37ae0652f0dd8650b35f99b Mon Sep 17 00:00:00 2001 From: "deepsource-autofix[bot]" <62050782+deepsource-autofix[bot]@users.noreply.github.com> Date: Fri, 29 Sep 2023 05:43:34 +0000 Subject: [PATCH] refactor: fix check for empty string It is not recommended to use `len` for empty string test. --- api/middleware.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/middleware.go b/api/middleware.go index e761f50..bfa2c75 100644 --- a/api/middleware.go +++ b/api/middleware.go @@ -18,7 +18,7 @@ const ( func authMiddleware(tokenMaker token.Maker) gin.HandlerFunc { return func(ctx *gin.Context) { authHeader := ctx.GetHeader(authHeaderKey) - if len(authHeader) == 0 { + if authHeader == "" { err := errors.New("authorization header is not provided") ctx.AbortWithStatusJSON(http.StatusUnauthorized, errorResponse(err)) return