Documentation ¶
Overview ¶
Package paginator provides a simple pagination utility for managing paginated queries.
Index ¶
Constants ¶
View Source
const ( MinPage = 1 // MinPage represents the minimum allowed value for the pagination query's Page parameter. MinPerPage = 1 // MinPerPage represents the minimum allowed value for the pagination query's PerPage parameter. MaxPerPage = 100 // MaxPerPage represents the maximum allowed value for the pagination query's PerPage parameter. )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Query ¶
type Query struct { Page int `query:"page"` // Page represents the current page number. PerPage int `query:"per_page"` // PerPage represents the number of items per page. }
Query represents the pagination query parameters.
func NewQuery ¶
func NewQuery() *Query
NewQuery creates a new pagination query with default values. If a custom pagination is provided in the request, it is advisable to normalize the values using the `Query.Normalize()` method.
func (*Query) Normalize ¶
func (q *Query) Normalize()
Normalize ensures valid values for Page and PerPage in the pagination query. If query.PerPage is less than one, it is set to `MinPerPage`. If query.Page is less than one, it is set to `MinPage`. The maximum allowed value for query.PerPage is `MaxPerPage`.
Click to show internal directories.
Click to hide internal directories.