Expand description
HTTP layer and REST endpoint implementations
This module provides generic HTTP/REST components for the Backbone CRUD system:
CrudServicetrait: Core async trait for entity CRUD operationsBackboneCrudHandler: Generic Axum router builder for all 11 endpoints- Response types:
ApiResponse,PaginatedResponse,BulkResponse
Re-exports§
pub use crate::permission::guarded;pub use crate::permission::guarded_all;pub use crate::permission::permission_refusal;pub use crate::permission::unauthenticated_refusal;pub use crate::permission::CrudPermissions;pub use crate::service::MAX_BATCH_SIZE;
Structs§
- ApiResponse
- Standard API response wrapper
- Backbone
Crud Handler - Generic Backbone CRUD handler that provides all 11 endpoints as an Axum router.
- Batch
IdsRequest - Request body carrying a list of entity ids — used by bulk soft-delete, bulk restore, and bulk permanent-delete endpoints.
- Bulk
Create Request - Bulk request for multiple entities
- Bulk
Patch Item - One element of the per-id form of a bulk PATCH request.
- Bulk
Preview - The answer of
POST {resource}/bulk/preview: what a bulk PATCH would do. - Bulk
Preview Row - One row of a bulk partial update’s dry run: the record as it is and as the patch would leave it, or the error the write would refuse it with.
- Bulk
Response - Bulk response
- Bulk
Update Item - One element of the
PUT {resource}/bulkarray: an id plus the (flattened) full update DTO for that row. - Field
Change - One field’s value before and after a previewed write.
- Filter
Options - Filtering and sorting options
- History
Entry - Parse the reserved
fieldskey (comma-separated) into trimmed field names. Absent/empty → empty vec, meaning “no projection — return every field”. One recorded change to a record. - List
Query - The list query extractor every generic list-shaped route takes:
ListQueryParamsread off the query string, where a paging value that is not a number is refused by NAME, as aninvalid_queryviolation on the parameter (page,limit), instead of axum’s bare “Failed to deserialize query string”. - List
Query Params - Generic list query parameters
- List
Request - Extended pagination request with filtering and sorting
- Paginated
ApiResponse - Paginated API response with success flag, data array, and metadata at top level This is the preferred response format for list endpoints
- Paginated
Response - Generic paginated response (without success wrapper)
- Pagination
Request - Pagination request (legacy)
- Pagination
Response - Pagination response metadata
- Preview
Change - A row a bulk PATCH would change.
- Preview
Refusal - A row a bulk PATCH would refuse.
- Upsert
Request - Upsert request (update or insert)
Enums§
- Access
Scope - Per-request access scope, injected by the application’s auth middleware as an axum
Extension.Platformsees everything (a superadmin / root caller);Company(id)is scoped to one tenant. - Bulk
Patch Request - Body for
PATCH {resource}/bulk. Accepts either a single patch applied to many ids, or a distinct patch per id. Shape is auto-detected. - Sort
Order - Sort order enum
Constants§
- INTERNAL_
ERROR_ MESSAGE - The sentence a 500 answers with. The real error is logged, never sent: it can carry SQL, table names and driver text a client has no use for and an attacker does.
- MAX_
PAGINATION_ OFFSET - Maximum number of rows offset pagination is allowed to skip. Requests that
would page deeper than this are rejected with
400so clients narrow their query with filters instead of deep-scanning the table (OFFSETcost grows with depth). AtMAX_PER_PAGEthis allows ~100 pages. - MAX_
PER_ PAGE - Hard cap on page size. Mirrors the clamp in
backbone_orm::PaginationParams::new(per_page.clamp(1, 100)); kept here so the offset-depth check below computes the same effective offset the DB uses. - NOT_
FOUND_ MESSAGE - The sentence a 404 answers with.
Traits§
- Backbone
Http Handler - Synchronous trait for HTTP handlers implementing Backbone CRUD operations.
- Crud
Service - Core trait that application services must implement for generic CRUD operations.
- History
Provider - Supplies a record’s change history to the generic CRUD router.
Functions§
- correlation_
middleware - Bind the request’s correlation id for the writes it makes, so the events they stage (and the logs and audit rows of the request) share one id.
- service_
error_ response - The response for a failed
ServiceError, for handlers outside the generic CRUD handler (a generated state-machine transition, a custom route) that call the service directly — the same answer the generic handler gives (seeservice_error_status). A 500 carriesINTERNAL_ERROR_MESSAGE; the error itself is logged. - service_
error_ status - The status a
ServiceErroranswers with, by variant. - without_
secrets - A response body for a hand-written or generated route outside the generic handler (a state transition, a verb) that returns an entity’s response DTO: the entity’s secrets stripped, and its private fields kept from every caller, as the generic write responses do.