Skip to content

Commit

Permalink
removes unecessary err - changes print to loggrus
Browse files Browse the repository at this point in the history
  • Loading branch information
mflilian committed Apr 13, 2022
1 parent f50befb commit 60f68bd
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion app/history.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ func HistoryHandler(app *App) func(c echo.Context) error {
return func(c echo.Context) error {
c.Set("route", "History")
topic := c.ParamValues()[0]
userID, from, limit, _, _ := ParseHistoryQueryParams(c, app.Defaults.LimitOfMessages)
userID, from, limit, _ := ParseHistoryQueryParams(c, app.Defaults.LimitOfMessages)
authenticated, _, err := IsAuthorized(c.StdContext(), app, userID, topic)
if err != nil {
return err
Expand Down
2 changes: 1 addition & 1 deletion app/history_v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func HistoryV2Handler(app *App) func(c echo.Context) error {
return func(c echo.Context) error {
c.Set("route", "HistoryV2")
topic := c.ParamValues()[0]
userID, from, limit, isBlocked, _ := ParseHistoryQueryParams(c, app.Defaults.LimitOfMessages)
userID, from, limit, isBlocked := ParseHistoryQueryParams(c, app.Defaults.LimitOfMessages)
authenticated, _, err := IsAuthorized(c.StdContext(), app, userID, topic)
if err != nil {
return err
Expand Down
11 changes: 6 additions & 5 deletions app/query_param.go
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
package app

import (
"fmt"
"strconv"
"strings"
"time"

"github.com/labstack/echo"

log "github.com/sirupsen/logrus"
)

func ParseHistoryQueryParams(c echo.Context, defaultLimit int64) (string, int64, int64, bool, error) {
func ParseHistoryQueryParams(c echo.Context, defaultLimit int64) (string, int64, int64, bool) {
userID := c.QueryParam("userid")
from, _ := strconv.ParseInt(c.QueryParam("from"), 10, 64)
limit, _ := strconv.ParseInt(c.QueryParam("limit"), 10, 64)
Expand All @@ -25,11 +26,11 @@ func ParseHistoryQueryParams(c echo.Context, defaultLimit int64) (string, int64,

if err != nil {
// If it returns error, it will assume the default behavior(e.g. isBlocked=false).
fmt.Println("ERROR:", err)
return userID, from, limit, false, err
log.Warningln(err)
return userID, from, limit, false
}

return userID, from, limit, isBlocked, nil
return userID, from, limit, isBlocked
}

func ParseHistoriesQueryParams(c echo.Context, defaultLimit int64) ([]string, string, int64, int64) {
Expand Down

0 comments on commit 60f68bd

Please sign in to comment.