Documentation ¶
Overview ¶
Package pagination implements a series of utilities for dealing with paginating lists of objects for an API.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidKeyString = errors.New("invalid pagination key string: must be 32-byte URL-safe base64")
ErrInvalidKeyString is returned when the string representing a key is malformed.
var ErrInvalidToken = errors.New("invalid or expired pagination token")
ErrInvalidToken is returned when a token fails to Unmarshal because it was invalid or expired.
var FirstPageToken = Token("")
FirstPageToken is used to represent the first page of content.
Functions ¶
This section is empty.
Types ¶
type Key ¶
type Key struct {
// contains filtered or unexported fields
}
Key represents the key used to cryptographically secure the token being used to keep track of pages.
func KeyFromString ¶
KeyFromString creates the key for a given string.
Strings must be 32-byte URL-safe base64 representations of the key bytes.
func Must ¶
Must is a helper that wraps calls returning a Key and and error and panics if the error is non-nil.
func (Key) MarshalToken ¶
MarshalToken encodes an interface into JSON bytes and produces a Token.
func (Key) UnmarshalToken ¶
UnmarshalToken decrypts a Token using provided key and decodes the result into the provided interface.