pagination

package
v0.0.0-...-c824f4b Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2024 License: Apache-2.0 Imports: 5 Imported by: 1

Documentation

Overview

Package pagination provides a simple pagination helpers that can be used for API pagination purposes.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeToken

func DecodeToken[T any](token string) (T, error)

DecodeToken decodes a gob encoded string into an input struct.

func TokenizeStruct

func TokenizeStruct(in any) (string, error)

TokenizeStruct encodes input value as a gob.Encoded string. The input should be a non exported golang struct, that contains exported fields, that could be decoded with a valid Next filter expression. The output string is a url safe base64 encoded gob of this struct.

Types

type NextTokenExpr

type NextTokenExpr struct {
	// Filter is a filter expression, that should be used to filter the next page.
	Filter expr.FilterExpr

	// OrderBy is an optional ordering expression, that should be used to order the next page.
	OrderBy *expr.OrderByExpr
}

NextTokenExpr is a pagination token filter expression. This can be used directly as a token struct, or embeddable in some internal packages for open-source implementations.

func (*NextTokenExpr) Free

func (n *NextTokenExpr) Free()

Free returns the allocated memory for both Filter and OrderBy fields.

Jump to

Keyboard shortcuts

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