mirror of
https://gitea.com/gitea/tea
synced 2024-11-08 19:10:28 +00:00
59fe58577a
Migrate Update code.gitea.io/sdk/gitea to v0.12.0. Co-authored-by: 6543 <6543@obermui.de> Reviewed-on: https://gitea.com/gitea/tea/pulls/133 Reviewed-by: Andrew Thornton <art27@cantab.net> Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
38 lines
718 B
Go
38 lines
718 B
Go
// Copyright 2020 The Gitea Authors. All rights reserved.
|
|
// Use of this source code is governed by a MIT-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
package gitea
|
|
|
|
import (
|
|
"fmt"
|
|
"net/url"
|
|
)
|
|
|
|
const defaultPageSize = 10
|
|
const maxPageSize = 50
|
|
|
|
// ListOptions options for using Gitea's API pagination
|
|
type ListOptions struct {
|
|
Page int
|
|
PageSize int
|
|
}
|
|
|
|
func (o ListOptions) getURLQuery() url.Values {
|
|
query := make(url.Values)
|
|
query.Add("page", fmt.Sprintf("%d", o.Page))
|
|
query.Add("limit", fmt.Sprintf("%d", o.PageSize))
|
|
|
|
return query
|
|
}
|
|
|
|
func (o ListOptions) setDefaults() {
|
|
if o.Page < 1 {
|
|
o.Page = 1
|
|
}
|
|
|
|
if o.PageSize < 0 || o.PageSize > maxPageSize {
|
|
o.PageSize = defaultPageSize
|
|
}
|
|
}
|