Documentation
¶
Index ¶
- Constants
- func EncodeCursor(c Cursor) string
- func EncodeDocumentationCursor(createdAt time.Time, internalID int64) string
- func EncodeDocumentationStringCursor(occurredAt time.Time, id string) string
- func EncodeStringCursor(c StringCursor) string
- func Init(key []byte)
- type Cursor
- type Direction
- type PageInfo
- func BuildPage[T any](items []T, limit int32, cursorDir *Direction, getCreatedAt func(T) time.Time, ...) ([]T, PageInfo)
- func BuildPageString[T any](items []T, limit int32, cursorDir *Direction, getOccurredAt func(T) time.Time, ...) ([]T, PageInfo)
- func BuildPageStringWithSearchRank[T any](items []T, limit int32, cursorDir *Direction, searchRankEnabled bool, ...) ([]T, PageInfo)
- type StringCursor
Constants ¶
const DocumentationHMACKey = "openmrp-openapi-documentation-cursor-key-v1"
DocumentationHMACKey signs OpenAPI example cursors. It is not used at runtime.
Variables ¶
This section is empty.
Functions ¶
func EncodeCursor ¶
func EncodeDocumentationCursor ¶
EncodeDocumentationCursor returns a signed forward cursor for OpenAPI list examples using pagination.Cursor (int64 internal IDs).
func EncodeDocumentationStringCursor ¶
EncodeDocumentationStringCursor returns a signed forward cursor for OpenAPI list examples using pagination.StringCursor (varchar primary keys / type IDs).
func EncodeStringCursor ¶
func EncodeStringCursor(c StringCursor) string
Types ¶
type Cursor ¶
type Cursor struct {
CreatedAt time.Time `json:"c"`
ID int64 `json:"i"`
Direction Direction `json:"d"`
}
func DecodeCursor ¶
type PageInfo ¶
func BuildPage ¶
func BuildPage[T any]( items []T, limit int32, cursorDir *Direction, getCreatedAt func(T) time.Time, getID func(T) int64, ) ([]T, PageInfo)
BuildPage trims the limit+1 slice, reverses if backward, and computes PageInfo. cursorDir is nil for first-page requests.
func BuildPageString ¶
func BuildPageString[T any]( items []T, limit int32, cursorDir *Direction, getOccurredAt func(T) time.Time, getID func(T) string, ) ([]T, PageInfo)
BuildPageString is like BuildPage but uses string IDs with StringCursor, for tables whose primary key is a varchar.
func BuildPageStringWithSearchRank ¶
func BuildPageStringWithSearchRank[T any]( items []T, limit int32, cursorDir *Direction, searchRankEnabled bool, getOccurredAt func(T) time.Time, getID func(T) string, getMatchTier func(T) int32, ) ([]T, PageInfo)
BuildPageStringWithSearchRank is like BuildPageString but embeds MatchTier in cursors when searchRankEnabled is true (catalog search relevance pagination).
type StringCursor ¶
type StringCursor struct {
OccurredAt time.Time `json:"c"`
ID string `json:"s"`
Direction Direction `json:"d"`
// MatchTier is set for ranked catalog search pagination (exact/prefix/substring SKU tiers).
MatchTier *int `json:"t,omitempty"`
}
StringCursor is like Cursor but uses a string ID instead of int64, for tables whose primary key is a varchar (e.g. request_log).
func DecodeStringCursor ¶
func DecodeStringCursor(s string) (StringCursor, error)