[chore] much improved paging package (#2182)

This commit is contained in:
kim
2023-09-07 15:58:37 +01:00
committed by GitHub
parent 14ef098099
commit b093947d84
15 changed files with 1154 additions and 445 deletions

View File

@@ -103,8 +103,12 @@ func (m *Module) BlocksGETHandler(c *gin.Context) {
return
}
limit, errWithCode := apiutil.ParseLimit(c.Query(LimitKey), 20, 100, 2)
if err != nil {
page, errWithCode := paging.ParseIDPage(c,
1, // min limit
100, // max limit
20, // default limit
)
if errWithCode != nil {
apiutil.ErrorHandler(c, errWithCode, m.processor.InstanceGetV1)
return
}
@@ -112,11 +116,7 @@ func (m *Module) BlocksGETHandler(c *gin.Context) {
resp, errWithCode := m.processor.BlocksGet(
c.Request.Context(),
authed.Account,
paging.Pager{
SinceID: c.Query(SinceIDKey),
MaxID: c.Query(MaxIDKey),
Limit: limit,
},
page,
)
if errWithCode != nil {
apiutil.ErrorHandler(c, errWithCode, m.processor.InstanceGetV1)