Expand description
Public entrypoint for the Vantus framework.
Most application code only needs the re-exports from this file:
HostBuilder for bootstrapping, #[module] / #[controller]
for structure, and the typed request extractors for handlers.
use vantus::{HostBuilder, RequestContext, Response, module};
#[derive(Clone)]
struct HealthModule;
#[module]
impl HealthModule {
#[vantus::get("/health")]
fn health(&self, ctx: RequestContext) -> Response {
Response::json_value(serde_json::json!({
"service": ctx.app_config().service_name,
"status": "ok",
}))
}
}
fn main() {
let mut builder = HostBuilder::new();
builder.compose_with_config(|_configuration, _app, context| {
context.module(HealthModule);
Ok(())
});
builder.build().run_blocking();
}Structs§
- AppConfig
- Built-in framework configuration model.
- Application
Host - Atomic
IdGenerator - Cheap monotonic ID generator backed by an atomic counter.
- Body
Bytes - Zero-copy request body bytes.
- CliFeature
Defaults - Default states for first-party modules when the CLI does not override them.
- Configuration
- Layered key-value configuration store used by the framework.
- Configuration
Builder - Builder for layered configuration loading.
- Global
Rate Limiter - Header
- Extracts and parses a named request header.
- Health
Module - Host
Builder - Fluent application bootstrap API.
- Host
Context - Runtime context passed to lifecycle hooks.
- Http
Error - Identity
State - Typed request identity inserted by middleware.
- Info
Module - Json
Body - JSON request body extractor.
- Observability
Module - Panic
Recovery - Path
- Extracts a named path segment from the matched route.
- Query
- Extracts a named query-string value.
- Query
Map - Provides access to the full query map.
- Readiness
Check - Readiness
Registry - Request
- Request
Context - Per-request framework context passed to handlers and middleware.
- Request
Id - Request
LogEvent - Structured request log payload emitted by framework middleware.
- Request
Logger - Request
State - Typed request-local state inserted by middleware.
- Response
- Runtime
Snapshot - Runtime
State - Security
Headers - Server
Cli - First-party CLI bootstrap for Vantus applications.
- Server
Config - Parsed server settings from
AppConfig. - Server
Handle - Server
Options - Runtime-ready server settings after validation.
- StdIo
LogSink - Default sink that writes JSON to stdout/stderr without installing tracing globals.
- Text
Body - UTF-8 text body extractor.
- Uuid
IdGenerator - UUID-backed generator for globally unique identifiers.
- WebPlatform
Module
Enums§
- CliError
- Config
Error - Errors produced while loading or binding configuration.
- Extractor
Error - Framework
Error - Host
Build Error - Host
Error - IdGenerator
Kind - Shared ID generator choices exposed by the CLI.
- LogLevel
- Coarse log level used by the framework’s default sink abstraction.
- Method
- Middleware
Stage - Parse
Error - Runtime
Mode - Runtime preset applied by the CLI.
- Server
Protocol - Server protocol mode selected from configuration.
Traits§
- Controller
- Marker trait for route-focused types.
- From
Config - Projects a sub-config from an already bound root config.
- From
Configuration - Manual configuration binding contract.
- From
Request - Generic extraction contract for handler parameters.
- IdGenerator
- Shared service contract for generating application identifiers.
- Identity
- Marker trait for request-scoped caller identity payloads inserted by middleware.
- Into
Handler Result - Compatibility shim for the older macro return-conversion name.
- Into
Response - Converts typed handler return values into the framework response model.
- LogSink
- Destination for text and structured request logs emitted by the framework.
- Middleware
- Module
- The core application building block in Vantus.
- Named
From Request - Named extraction contract used by
Path<T>andQuery<T>. - Named
Optional From Request - Optional named extraction contract used by
Option<Query<T>>andOption<Header<T>>. - Optional
From Request - Optional extraction contract used for safe request-derived inputs.
- Readiness
Contributor - Runtime
Module - Optional lifecycle hooks for long-lived application modules.
Functions§
- emit_
default_ log - redact_
headers - Redacts sensitive header values before they are copied into logs.
- sanitize_
log_ message - Best-effort secret scrubbing for ad-hoc log messages.
- sanitize_
path_ for_ logs - Scrubs path segments that look like identifiers before logging.
Type Aliases§
Attribute Macros§
- async_
trait - controller
- Attribute macros used to define route-bearing modules and controllers.
- delete
- Attribute macros used to define route-bearing modules and controllers.
- get
- Attribute macros used to define route-bearing modules and controllers.
- head
- Attribute macros used to define route-bearing modules and controllers.
- middleware
- Attribute macros used to define route-bearing modules and controllers.
- module
- Attribute macros used to define route-bearing modules and controllers.
- options
- Attribute macros used to define route-bearing modules and controllers.
- patch
- Attribute macros used to define route-bearing modules and controllers.
- post
- Attribute macros used to define route-bearing modules and controllers.
- put
- Attribute macros used to define route-bearing modules and controllers.