vantus
vantus is a macro-first async Rust backend framework built around explicit composition, typed request extraction, and production-oriented HTTP defaults.
Companion docs:
- docs/cli-reference.md
- docs/quick-start.md
- docs/configuration-reference.md
- docs/production-notes.md
- docs/publishing-checklist.md
- SECURITY.md
Core model
- Use
HostBuilderto load configuration, apply runtime limits, and mount modules. - Use
#[module]and#[controller]for route definition. - Construct application dependencies yourself with normal Rust constructors and pass them into modules/controllers explicitly.
- Use request-derived handler inputs only:
RequestContext,Path<T>,Query<T>,Header<T>,QueryMap,BodyBytes,TextBody,JsonBody<T>,RequestState<T>,IdentityState<T>, and safe optional variants.
Runtime DI-style handler injection is no longer part of the supported public API.
Quick start
use Duration;
use Serialize;
use ;
See examples/main.rs for the runnable example.
Request contracts
Route contracts are inferred from handler signatures and enforced before the handler runs.
JsonBody<T>requiresContent-Type: application/jsonTextBodyrequiresContent-Type: text/plainBodyBytesaccepts any media type- handlers without a body extractor reject non-empty request bodies
GET,HEAD, andOPTIONShandlers cannot declare body extractors- wrong-method matches return
405 Method Not Allowedwith anAllowheader
Middleware
Attach middleware declaratively with #[middleware(Type)] on a module/controller impl or an individual route method.
- middleware types must implement
MiddlewareandDefault - impl-level middleware wraps route-level middleware
- repeated attributes run in source order
Observability
ObservabilityModule adds:
X-Request-Idgeneration using the configuredIdGenerator- structured request logging
/live,/ready,/diag, and/metrics- readiness contributor registration
- runtime counters and per-route latency totals
vantus does not install a global tracing subscriber or exporter for you. Wire those explicitly in your binary so logging, tracing, and metrics stay under application control.
The default ID generator is UuidIdGenerator. AtomicIdGenerator remains available for tests and local demos, but it is no longer the default.
Configuration
ConfigurationBuilder merges:
application.propertiesapplication.{profile}.properties- environment variables with the configured prefix, default
APP_
AppConfig remains the built-in runtime configuration model. For application-specific config, bind your own type from Configuration inside compose_with_config(...) and pass the resulting values into your modules explicitly.
Security and operations
HostBuilder::max_body_size(...)enforces request body size before middlewareHostBuilder::request_timeout(...)sets the outer request deadlineHostBuilder::rate_limiter(...)applies pre-middleware token-bucket throttling- HTTP/1.1 requests require a valid
Hostheader - content-type and method/body mismatches are rejected early
- TLS termination, CORS, compression, and auth helpers are intentionally left to middleware or a front proxy in this release
- CI runs
cargo auditandcargo deny - Dependabot is configured for Cargo crates and GitHub Actions updates
Publishing
Before publishing, walk through docs/publishing-checklist.md and confirm SECURITY.md still matches your disclosure workflow.
Optional CLI
Enable the cli feature when you want first-party runtime flag parsing for environment/profile selection, feature toggles, rate limiting, request limits, and startup dry-runs.
Verification
$env:CARGO_TARGET_DIR="target_plan"