pagination

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// MaxPageSize is the maximum page size allowed
	MaxPageSize = 100

	// ResponseHeaderName describes the header name for the pagination response
	ResponseHeaderName = "X-Pagination"
)

Variables

View Source
var (
	// OrderByRegex is the regex for the orderBy field
	OrderByRegex = fmt.Sprintf("^[A-Z0-9_]+_(%v|%v)$", cdbp.OrderAscending, cdbp.OrderDescending)
)

Functions

This section is empty.

Types

type PageRequest

type PageRequest struct {
	// Name is the name of the Allocation
	PageNumber *int `query:"pageNumber"`
	// Description is the description of the Allocation
	PageSize *int `query:"pageSize"`
	// OrderByStr is the order by field
	OrderByStr *string `query:"orderBy"`

	// Offset is the offset of the pagination
	Offset *int
	// Limit is the limit of the pagination
	Limit *int
	// OrderBy is the processed order by field
	OrderBy *cdbp.OrderBy
}

PageRequest captures and validates pagination data

func (*PageRequest) ConvertToDB

func (pr *PageRequest) ConvertToDB() cdbp.PageInput

func (*PageRequest) Validate

func (pr *PageRequest) Validate(orderByFields []string) error

Validate ensure the values passed in request are acceptable

type PageResponse

type PageResponse struct {
	// PageNumber is the page number
	PageNumber int `json:"pageNumber"`
	// PageSize is the page size
	PageSize int `json:"pageSize"`
	// Total is the total number of items
	Total int `json:"total"`
	// OrderBy is the order by field
	OrderBy *string `json:"orderBy"`
}

PageResponse is the response for a paginated request

func NewPageResponse

func NewPageResponse(pageNumber int, pageSize int, total int, orderBy *string) *PageResponse

NewPageResponse creates a new PageResponse

Jump to

Keyboard shortcuts

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