Help us shape the future of Go! Take the 2026 Go Developer Survey

paging

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2021 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultPageSize     = 10
	PageStartQueryParam = "s"
	PageEndQueryParam   = "e"
	PageSizeQueryParam  = "l"
)

Functions

This section is empty.

Types

type FirstSpec

type FirstSpec struct {
	PageSize int `json:"size"`
}

func (*FirstSpec) Query

func (f *FirstSpec) Query(query *url.Values)

func (*FirstSpec) Size

func (f *FirstSpec) Size() int

type FullSpec

type FullSpec struct {
	// StartIDIncl is the start ID (inclusive), might be empty if page contains no elements
	StartIDIncl string `json:"start,omitempty"`
	// EndIDIncl is the end ID (inclusive), might be empty if page contains no elements
	EndIDIncl string `json:"end,omitempty"`
	PageSize  int    `json:"size"`
}

func (*FullSpec) Next

func (p *FullSpec) Next() NextSpec

func (*FullSpec) Prev

func (p *FullSpec) Prev() PreviousSpec

func (*FullSpec) Query

func (f *FullSpec) Query(query *url.Values)

func (*FullSpec) Size

func (f *FullSpec) Size() int

type NextSpec

type NextSpec struct {
	StartIDExcl string `json:"start"`
	PageSize    int    `json:"size"`
}

func (*NextSpec) Query

func (f *NextSpec) Query(query *url.Values)

func (*NextSpec) Size

func (f *NextSpec) Size() int

type Page

type Page interface {
	Size() int
	Query(query *url.Values)
}

func FromQuery

func FromQuery(c *gin.Context) Page

type Paging

type Paging struct {
	Previous *PreviousSpec `json:"prev,omitempty"`
	Current  FullSpec      `json:"cur"`
	Next     *NextSpec     `json:"next,omitempty"`
}

type PreviousSpec

type PreviousSpec struct {
	EndIDExcl string `json:"end"`
	PageSize  int    `json:"size"`
}

func (*PreviousSpec) Query

func (f *PreviousSpec) Query(query *url.Values)

func (*PreviousSpec) Size

func (f *PreviousSpec) Size() int

Jump to

Keyboard shortcuts

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