pagination

package
v1.29.0 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2026 License: MIT Imports: 11 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Paginate added in v1.3.0

func Paginate[TItem any](p *Paginator, paginatedHandler TPaginatedHandler[TItem]) 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

Types

type PaginatedHandler

type PaginatedHandler func(w http.ResponseWriter, r *http.Request, limit int, offset int) (items any, totalCount int, eventErrors *models.Error)

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)

type TPaginatedHandler added in v1.3.0

type TPaginatedHandler[TItem any] func(w http.ResponseWriter, r *http.Request, limit int, offset int) (successResult *models.PaginationSuccessResult[TItem], errorResult *models.ErrorResult[models.Error])

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

Jump to

Keyboard shortcuts

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