pagination

package
v0.27.0 Latest Latest
Warning

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

Go to latest
Published: May 18, 2023 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitialisePagination added in v0.21.0

func InitialisePagination(cfg *config.Config, offsetParam, limitParam string) (offset, limit int, err error)

InitialisePagination creates a Paginator and uses it to validate, and set, the offset and limit parameters.

Types

type PaginatedResponse

type PaginatedResponse struct {
	Count      int `json:"count"`
	Offset     int `json:"offset"`
	Limit      int `json:"limit"`
	TotalCount int `json:"total_count"`
}

PaginatedResponse represents the pagination related values that go into list based response

type Paginator

type Paginator struct {
	DefaultLimit    int
	DefaultOffset   int
	DefaultMaxLimit int
}

Paginator is a type to hold pagination related defaults, and provides helper functions using the defaults if needed

func NewPaginator

func NewPaginator(defaultLimit, defaultOffset, defaultMaxLimit int) *Paginator

NewPaginator creates a new instance

func (*Paginator) ValidateParameters added in v0.21.0

func (p *Paginator) ValidateParameters(offsetParameter, limitParameter string) (offset, limit int, err error)

ValidateParameters returns pagination related values based on the given request.

Jump to

Keyboard shortcuts

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