Skip to content

Commit 18841cc

Browse files
committed
add check offset and limit in PaginationRequest
1 parent 18526e1 commit 18841cc

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

api.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,12 @@ func (cpr *PaginationRequest) QueryParams() string {
1616
}
1717

1818
query := url.Values{}
19-
query.Set("limit", strconv.Itoa(cpr.Limit))
20-
query.Set("offset", strconv.Itoa(cpr.Offset))
19+
if cpr.Limit > 0 {
20+
query.Set("limit", strconv.Itoa(cpr.Limit))
21+
}
22+
if cpr.Offset >= 0 {
23+
query.Set("offset", strconv.Itoa(cpr.Offset))
24+
}
2125

2226
return query.Encode()
2327
}

0 commit comments

Comments
 (0)