pagination

package
v1.0.0-beta.141 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 9, 2024 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type InvalidError

type InvalidError struct {
	// contains filtered or unexported fields
}

func (InvalidError) Error

func (e InvalidError) Error() string

type Page

type Page struct {
	PageSize   int `json:"pageSize"`
	PageNumber int `json:"page"`
}

func (Page) IsZero

func (p Page) IsZero() bool

func (Page) Limit

func (p Page) Limit() int

func (Page) Offset

func (p Page) Offset() int

func (Page) Validate

func (p Page) Validate() error

type PagedResponse

type PagedResponse[T any] struct {
	Page       Page `json:"-"`
	TotalCount int  `json:"totalCount"`
	Items      []T  `json:"items"`
}

func (PagedResponse[T]) MarshalJSON

func (p PagedResponse[T]) MarshalJSON() ([]byte, error)

Implement json.Marshaler interface to flatten the Page struct

type Paginator

type Paginator[T any] interface {
	Paginate(ctx context.Context, page Page) (PagedResponse[T], error)
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL