page

package
v0.0.0-...-da924b9 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package page provides support for query paging.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Document

type Document[T any] struct {
	Items       []T `json:"items"`
	Total       int `json:"total"`
	Page        int `json:"page"`
	RowsPerPage int `json:"rowsPerPage"`
}

Document is the form used for API responses from query API calls.

func NewDocument

func NewDocument[T any](items []T, total int, page int, rowsPerPage int) Document[T]

NewDocument constructs a response value for a web paging trusted.

func (Document[T]) Encode

func (d Document[T]) Encode() ([]byte, string, error)

Encode implments the encoder interface.

type Page

type Page struct {
	Number      int
	RowsPerPage int
}

Page represents the requested page and rows per page.

func Parse

func Parse(page string, rows string) (Page, error)

Parse parses the request for the page and rows query string. The defaults are provided as well.

Jump to

Keyboard shortcuts

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