Expand description
An opinionated full-stack Rust web framework with strong conventions and sensible defaults.
Capy integrates routing, validation, configuration, and database tooling with a predictable application structure.
Depend on this package as capy = { package = "capy-framework", version = "0.5.0" }.
The prelude contains the common API; named re-exports retain native escape hatches.
Re-exports§
pub use capy_db as db;pub use capy_http::schema;pub use axum;pub use chrono;pub use sea_orm;pub use sea_orm_migration as migration;pub use serde;pub use serde_json;pub use tokio;pub use tower;pub use tower_http;pub use tracing;pub use validator;pub use capy_testing as testing;
Modules§
- prelude
- The small set of types most API handlers need.
Structs§
- ApiDocument
- Standard OpenAPI 3.1 document. Advanced applications can customize its JSON.
- ApiError
Response - JSON wire envelope for Capy’s standardized errors. It never carries native causes.
- ApiRoute
Info - Public metadata displayed by
capy routes --api. - ApiSettings
- Small application-owned API metadata. Documentation is disabled by default.
- App
- Application builder: configuration, database, tracing, migrations, and HTTP.
- AppConfig
- Application and database settings, resolved before startup.
- AppContext
- Cheaply cloned state shared by every request.
- AppSettings
- HTTP server and logging settings. Environment variables use
APP_. - Context
- Extract typed application state using
Context(ctx): Context. - Created
- A JSON response with HTTP 201 Created.
- Database
Settings - SeaORM connection settings. Environment variables use
DATABASE_. - Health
Response - JSON wire data for process liveness.
- Http
Settings - Small HTTP policy surface, expressed in seconds and bytes to avoid ambiguous units.
- Json
- Deserialize or return JSON, using Capy’s safe rejection envelope.
Put this extractor last because it consumes the body. Native extraction is
available as
capy::axum::Json. - NoContent
- An empty response with HTTP 204 No Content.
- Page
- A bounded collection response. The caller supplies a paginated query’s rows.
- Page
Meta - Conventional pagination metadata. Empty collections have one empty page.
- Pagination
- Validated, one-based page parameters. Use
Query<Pagination>in a handler. Defaults to page 1 and 20 items; page size must be 1..=100. - Path
- Deserialize path parameters with safe Capy JSON rejections.
Native extraction remains available as
capy::axum::extract::Path. - Query
- Deserialize a query string with safe Capy JSON rejections.
Native extraction remains available as
capy::axum::extract::Query. - Readiness
Response - JSON wire data for a bounded database readiness probe.
- Request
Observation - Safe response-header completion data for optional application telemetry.
- Route
Info - A declared route, used by
capy routeswithout connecting to a database. - Routes
- A native Axum router together with a small, explicit route inventory.
- Server
Settings - Listener settings. Unspecified host/port retain legacy
APP_HOST/APP_PORT. - Validated
- Deserialize and validate a JSON body before invoking the handler. Put this extractor last, since it consumes the request body.
Enums§
- AppError
- Errors with predictable HTTP statuses and safe public messages.
Traits§
- ApiSchema
- A type which can be described as a JSON Schema document.
- Request
Observer - Application-owned telemetry adapter. Callbacks must be fast, nonblocking, and must not panic. Enqueue bounded events in your adapter for async exporters. No vendor, exporter, global registry, or background worker is installed by Capy.
Functions§
- health
- The default health response; it deliberately performs no database query.
- ready
- Readiness for standard DB-backed applications, with an independent probe deadline.
Mount beside
health, conventionally at/api/ready. Driver details never enter the response. Liveness remains independent of the database.
Type Aliases§
- Paginated
- JSON contract name for the existing bounded collection response.
- Pagination
Meta - JSON contract name for the existing pagination metadata.
- Result
- The result type used by application handlers and startup.
- Validation
Errors - Field names (including dotted nested paths) mapped to validation messages.
Derive Macros§
- ApiSchema
- Derive macro for
JsonSchematrait.