Skip to content

Commit

Permalink
chore: update pagination for getting all memos (#396)
Browse files Browse the repository at this point in the history
  • Loading branch information
boojack authored Nov 1, 2022
1 parent f8c0d73 commit b7fbbed
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions server/memo.go
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,10 @@ func (s *Server) registerMemoRoutes(g *echo.Group) {
return list[i].DisplayTs > list[j].DisplayTs
})

if memoFind.Limit != 0 {
list = list[memoFind.Offset:common.Min(len(list), memoFind.Offset+memoFind.Limit)]
}

c.Response().Header().Set(echo.HeaderContentType, echo.MIMEApplicationJSONCharsetUTF8)
if err := json.NewEncoder(c.Response().Writer).Encode(composeResponse(list)); err != nil {
return echo.NewHTTPError(http.StatusInternalServerError, "Failed to encode all memo list response").SetInternal(err)
Expand Down

0 comments on commit b7fbbed

Please sign in to comment.