ListFunctions: option to disable pagination (#509)

the sdk enforce pagination, but most list endpoints dont require it ...

close #507 fully

Reviewed-on: https://gitea.com/gitea/go-sdk/pulls/509
Reviewed-by: Andrew Thornton <art27@cantab.net>
Reviewed-by: John Olheiser <john.olheiser@gmail.com>
Co-authored-by: 6543 <6543@obermui.de>
Co-committed-by: 6543 <6543@obermui.de>
This commit is contained in:
6543 2021-03-31 04:28:44 +08:00 committed by John Olheiser
parent 0599915e88
commit 7de882b744
1 changed files with 5 additions and 1 deletions

View File

@ -27,8 +27,12 @@ func (o ListOptions) getURLQuery() url.Values {
}
// setDefaults set default pagination options if none or wrong are set
// if you set -1 as page it will set all to 0
func (o *ListOptions) setDefaults() {
if o.Page < 1 {
if o.Page < 0 {
o.Page, o.PageSize = 0, 0
return
} else if o.Page == 0 {
o.Page = 1
}