Documentation ¶
Overview ¶
package pagination implements a cursor-based pagination for the REST API, where the cursors are opaque strings that encode an index in a result set.
Index ¶
Constants ¶
View Source
const (
DefaultPageSize = 40
)
Variables ¶
This section is empty.
Functions ¶
func DefaultPaginate ¶
func DefaultPaginate[T any](ctx context.Context, lst []T) ([]T, models.PaginationInfo)
Returns the result of Paginate with a page size of DefaultPageSize
func Paginate ¶
func Paginate[T any](ctx context.Context, lst []T, spec *models.PaginationSpec) ([]T, models.PaginationInfo, error)
Returns a single page from the input, selected using the given pagination spec, along with a struct describing the pagination of the returned page. The input result set should be the same for every call that uses chained PaginationSpecs and PaginationInfos. If spec is nil, a default page size is used.
Errors are suitable to directly return to clients. An error is returned only if:
- the cursor is the empty string
- the cursor decodes to an out of bounds index in the input
- the cursor can't be decoded
- PageSize < 0
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.