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::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
Response - Bulk response
- Bulk
Update Item - One element of the
PUT {resource}/bulkarray: an id plus the (flattened) full update DTO for that row. - 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 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
- 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§
- 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.
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.