Skip to content

Commit

Permalink
✨ Impl query parameter offset
Browse files Browse the repository at this point in the history
  • Loading branch information
H1rono committed Jun 7, 2024
1 parent c2f0a10 commit 6badb6a
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions router/transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,19 @@ func (h Handlers) GetTransactions(c echo.Context) error {
}
limit = limitI
}
offset := 0
if offsetQuery := c.QueryParam("offset"); offsetQuery != "" {
offsetI, err := strconv.Atoi(offsetQuery)
if err != nil {
h.Logger.Info("could not parse limit as integer", zap.Error(err))
return echo.NewHTTPError(http.StatusBadRequest, err)
}
if offsetI < 0 {
h.Logger.Info("received negative offset", zap.Int("offset", offsetI))
return echo.NewHTTPError(http.StatusBadRequest, fmt.Errorf("negative offset(=%d) is invalid", offsetI))
}
offset = offsetI
}
var tag *string
if c.QueryParam("tag") != "" {
t := c.QueryParam("tag")
Expand All @@ -111,6 +124,7 @@ func (h Handlers) GetTransactions(c echo.Context) error {
Since: since,
Until: until,
Limit: limit,
Offset: offset,
Tag: tag,
Group: group,
Request: request,
Expand Down

0 comments on commit 6badb6a

Please sign in to comment.