Documentation
¶
Overview ¶
Package page provides a generic paginated list type used across service backends.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DecodeHMACToken ¶
DecodeHMACToken decodes and verifies an HMAC token, returning the index. Returns 0 on invalid or tampered tokens.
func DecodeToken ¶
DecodeToken decodes an opaque continuation token back into a page index. An empty string, malformed base64, or non-integer content all return 0 (start of list), which is safe to use directly as a slice offset.
func EncodeHMACToken ¶
EncodeHMACToken encodes an index as an HMAC-signed token. Token format: base64url(strconv(idx) + "." + hmac-sha256-hex(secret, strconv(idx))).
func EncodeToken ¶
EncodeToken encodes a page index as an opaque continuation token.
func ValidateToken ¶
ValidateToken checks if a continuation token is syntactically valid. Returns an error if the token is not valid base64 or doesn't decode to an integer.
Types ¶
type Page ¶
Page is a generic paginated list result. Data contains the items for this page. Next is an opaque continuation token; when empty there are no more pages.
func New ¶
New creates a Page from a fully sorted slice, applying cursor-based pagination. token is an opaque continuation token (empty starts from the beginning). limit is the requested page size; when <= 0 defaultLimit is used.