Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type PaginatedList ¶
type PaginatedList struct { Page int `json:"page"` PerPage int `json:"per_page"` PageCount int `json:"page_count"` TotalCount int `json:"total_count"` Items interface{} `json:"items"` }
PaginatedList represents a paginated list of data items.
func NewPaginatedList ¶
func NewPaginatedList(page, perPage, total int) *PaginatedList
NewPaginatedList creates a new Paginated instance. The page parameter is 1-based and refers to the current page index/number. The perPage parameter refers to the number of items on each page. And the total parameter specifies the total number of data items. If total is less than 0, it means total is unknown.
func (*PaginatedList) BuildLinkHeader ¶
func (p *PaginatedList) BuildLinkHeader(baseUrl string, defaultPerPage int) string
BuildLinkHeader returns an HTTP header containing the links about the pagination.
func (*PaginatedList) BuildLinks ¶
func (p *PaginatedList) BuildLinks(baseUrl string, defaultPerPage int) [4]string
BuildLinks returns the first, prev, next, and last links corresponding to the pagination. A link could be an empty string if it is not needed. For example, if the pagination is at the first page, then both first and prev links will be empty.
func (*PaginatedList) Limit ¶
func (p *PaginatedList) Limit() int
Limit returns the LIMIT value that can be used in a SQL statement.
func (*PaginatedList) Offset ¶
func (p *PaginatedList) Offset() int
Offset returns the OFFSET value that can be used in a SQL statement.