Skip to main content

Module query

Module query 

Source
Expand description

Shared query helpers for the v2 API.

Pagination caps, sparse-field selection, and the meta envelope.

Structs§

DetailFields
The query a detail endpoint accepts.
ListEnvelope
The standard list envelope: { meta: { total_count, limit, offset }, items: [...] }.
ListMeta
ListQuery
Common query parameters that work across every list endpoint.
OrderSpec
(direction, field) parsed from one order= segment.
Path
axum::extract::Path, rejecting in JSON.
Query
axum::extract::Query, rejecting in JSON.

Constants§

DEFAULT_LIMIT
Default page size when ?limit= is omitted.
MAX_LIMIT
Hard cap on ?limit=. Beyond this, slow clients can DoS the cms with one request.

Functions§

apply_fields
Apply a sparse-field filter in place. meta and id are always preserved so consumers can still walk the response.
clamp_limit
Clamp a requested page size into 1..=MAX_LIMIT, defaulting when absent. Shared so every list endpoint agrees on the bounds — the menus list previously re-derived them and could have drifted.
clamp_page_size
The page-size rule, for a surface with its own bounds (the MCP tools allow larger pages than the public API): default when absent, else clamped into 1..=max.
empty_as_none
Deserialize an optional query parameter, treating an empty value as absent.
empty_string_as_none
Like empty_as_none for string parameters: ?locale= means “not specified”, never the locale whose code is the empty string.
field_set
Parsed sparse-field selector. None means “no selection — return every field”; Some(set) means “only these top-level keys”.
paginate
Clamped (limit, offset) from a ListQuery.
parse_order
Parse ?order= into a vector of OrderSpecs in declaration order. Empty input → empty vec (caller falls back to its default).
parse_order_in
Parse ?order=, refusing a field this endpoint cannot sort by.
parse_updated_since
Parse ?updated_since= as RFC 3339.
validate_fields
Refuse a ?fields= name the serializer never emits.