Skip to content

Commit

Permalink
refactor: fix check for empty string
Browse files Browse the repository at this point in the history
It is not recommended to use `len` for empty string test.
  • Loading branch information
deepsource-autofix[bot] authored Sep 29, 2023
1 parent 7e7e6a8 commit eda8f73
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion api/middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit eda8f73

Please sign in to comment.