pagination

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: May 30, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PaginatedHandler

type PaginatedHandler func(w http.ResponseWriter, r *http.Request, limit int, offset int) (list interface{}, totalCount int, errBundles *models.Error)

PaginatedHandler is a func type for an endpoint that returns a list of values that we want to paginate

type PaginatedResponse

type PaginatedResponse struct {
	Items                   interface{} `json:"items"`
	models.PaginationFields             // embedded, flattening fields into JSON
}

type Paginator

type Paginator struct {
	DefaultLimit    int
	DefaultOffset   int
	DefaultMaxLimit int
}

func NewPaginator

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

func (*Paginator) Paginate

func (p *Paginator) Paginate(paginatedHandler PaginatedHandler) func(w http.ResponseWriter, r *http.Request)

Paginate wraps a http endpoint to return a paginated list from the list returned by the provided function

Jump to

Keyboard shortcuts

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