Skip to main content

Module http

Module http 

Source
Expand description

HTTP layer and REST endpoint implementations

This module provides generic HTTP/REST components for the Backbone CRUD system:

  • CrudService trait: Core async trait for entity CRUD operations
  • BackboneCrudHandler: 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
BackboneCrudHandler
Generic Backbone CRUD handler that provides all 11 endpoints as an Axum router.
BatchIdsRequest
Request body carrying a list of entity ids — used by bulk soft-delete, bulk restore, and bulk permanent-delete endpoints.
BulkCreateRequest
Bulk request for multiple entities
BulkPatchItem
One element of the per-id form of a bulk PATCH request.
BulkResponse
Bulk response
BulkUpdateItem
One element of the PUT {resource}/bulk array: an id plus the (flattened) full update DTO for that row.
FilterOptions
Filtering and sorting options
HistoryEntry
Parse the reserved fields key (comma-separated) into trimmed field names. Absent/empty → empty vec, meaning “no projection — return every field”. One recorded change to a record.
ListQueryParams
Generic list query parameters
ListRequest
Extended pagination request with filtering and sorting
PaginatedApiResponse
Paginated API response with success flag, data array, and metadata at top level This is the preferred response format for list endpoints
PaginatedResponse
Generic paginated response (without success wrapper)
PaginationRequest
Pagination request (legacy)
PaginationResponse
Pagination response metadata
UpsertRequest
Upsert request (update or insert)

Enums§

AccessScope
Per-request access scope, injected by the application’s auth middleware as an axum Extension. Platform sees everything (a superadmin / root caller); Company(id) is scoped to one tenant.
BulkPatchRequest
Body for PATCH {resource}/bulk. Accepts either a single patch applied to many ids, or a distinct patch per id. Shape is auto-detected.
SortOrder
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 400 so clients narrow their query with filters instead of deep-scanning the table (OFFSET cost grows with depth). At MAX_PER_PAGE this 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§

BackboneHttpHandler
Synchronous trait for HTTP handlers implementing Backbone CRUD operations.
CrudService
Core trait that application services must implement for generic CRUD operations.
HistoryProvider
Supplies a record’s change history to the generic CRUD router.