API Reference
Builder Methods
| Method | Description |
|---|---|
LithairServer::new() | Create a new server builder |
.with_port(port) | Set the listening port |
.with_frontend_at(route, dir) | Serve static files from a directory |
.with_model::<T>(data_path, route_base) | Register a model with auto-generated CRUD |
.with_sessions(manager) | Enable session management |
.with_mfa_totp(config) | Enable MFA/TOTP endpoints |
.with_rbac_config(config) | Enable role-based access control |
.with_firewall_config(config) | Enable IP filtering and rate limiting |
.with_route_guard(pattern, guard) | Protect routes matching a pattern |
.with_data_admin() | Enable the data admin API |
.serve().await | Start the server (async) |
Model Attributes
| Attribute | Description |
|---|---|
#[db(indexed)] | Create an index on this field |
#[db(unique)] | Enforce uniqueness on this field |
#[http(expose)] | Expose field in REST API |
#[http(validate = "...")] | Add validation rule (e.g. non_empty) |
#[lifecycle(immutable)] | Prevent modification after creation |
#[lifecycle(audited)] | Track changes to this field |
#[lifecycle(versioned)] | Keep historical versions |
#[permission(write = "Role")] | Require role for write access |
#[retention(memory = N)] | Struct-level: cap in-memory items |
#[pinned] | Exempt a field's record from retention eviction |