keysetpagination

package
v0.0.487 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2022 License: Apache-2.0 Imports: 6 Imported by: 11

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Header(w http.ResponseWriter, u *url.URL, p *Paginator)

Header adds the Link header for the page encoded by the paginator. It contains links to the first and next page, if one exists.

func Paginate

func Paginate[I Item](p *Paginator) pop.ScopeFunc

Paginate returns a function that paginates a pop.Query. Usage:

q := c.Where("foo = ?", foo).Scope(keysetpagination.Paginate[Item](paginator))

Types

type Item

type Item interface{ PageToken() string }

type Option

type Option func(*Paginator) *Paginator

func Parse

func Parse(q *url.Values) ([]Option, error)

Parse returns the pagination options from the URL query.

func WithDefaultSize

func WithDefaultSize(size int) Option

func WithDefaultToken

func WithDefaultToken(t string) Option

func WithMaxSize

func WithMaxSize(size int) Option

func WithSize

func WithSize(size int) Option

func WithToken

func WithToken(t string) Option

type Paginator

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

func GetPaginator

func GetPaginator(modifiers ...Option) *Paginator

func Result

func Result[I Item](items []I, p *Paginator) ([]I, *Paginator)

Result removes the last item (if applicable) and returns the paginator for the next page.

func (*Paginator) IsLast

func (p *Paginator) IsLast() bool

func (*Paginator) Size

func (p *Paginator) Size() int

func (*Paginator) ToOptions

func (p *Paginator) ToOptions() []Option

func (*Paginator) Token

func (p *Paginator) Token() string

Jump to

Keyboard shortcuts

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