Skip to content

Commit

Permalink
refactor code
Browse files Browse the repository at this point in the history
  • Loading branch information
le-xuan-quynh committed May 1, 2022
1 parent d9e3359 commit 78903fc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
9 changes: 8 additions & 1 deletion internal/database/postgres-repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ package database

import (
"context"
"database/sql"
"github.com/hashicorp/go-hclog"
"github.com/jmoiron/sqlx"
uuid "github.com/satori/go.uuid"
"log"
"time"
)

Expand Down Expand Up @@ -179,7 +181,12 @@ func (repo *postgresRepository) GetListOfPasswords(ctx context.Context, userID s
if err != nil {
return nil, err
}
defer rows.Close()
defer func(rows *sql.Rows) {
err := rows.Close()
if err != nil {
log.Println(err)
}
}(rows)
var passwords []string
for rows.Next() {
var password string
Expand Down
4 changes: 1 addition & 3 deletions pkg/authorization/middleware/middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,7 @@ func ValidateParamRequest(validator *database.Validation, logger hclog.Logger) e
logger.Error("validation of verification data json failed", "error", errs)
return nil, errors.New("please check your param request")
}
resp, err = next(ctx, request)
return
return next(ctx, request)
}
}
}
Expand All @@ -127,7 +126,6 @@ func RateLimitRequest(tb *ratelimit.Bucket, logger hclog.Logger) endpoint.Middle
return nil, errors.New("you request too fast, please slow down")
}
return next(ctx, request)
return
}
}
}

0 comments on commit 78903fc

Please sign in to comment.