Unverified Commit b7fbbed8 authored by boojack's avatar boojack Committed by GitHub

chore: update pagination for getting all memos (#396)

parent f8c0d73d
...@@ -341,6 +341,10 @@ func (s *Server) registerMemoRoutes(g *echo.Group) { ...@@ -341,6 +341,10 @@ func (s *Server) registerMemoRoutes(g *echo.Group) {
return list[i].DisplayTs > list[j].DisplayTs 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) c.Response().Header().Set(echo.HeaderContentType, echo.MIMEApplicationJSONCharsetUTF8)
if err := json.NewEncoder(c.Response().Writer).Encode(composeResponse(list)); err != nil { 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) return echo.NewHTTPError(http.StatusInternalServerError, "Failed to encode all memo list response").SetInternal(err)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment