Expand description
§attuned-http
HTTP reference server for Attuned.
This crate provides a ready-to-use HTTP server exposing the Attuned API. It includes health checks, metrics, and OpenAPI documentation.
§Endpoints
POST /v1/state- Upsert state (patch semantics, optionally with inference)GET /v1/state/{user_id}- Get latest stateGET /v1/context/{user_id}- Get PromptContextDELETE /v1/state/{user_id}- Delete statePOST /v1/infer- Infer axes from message text (requires “inference” feature)GET /health- Health checkGET /metrics- Prometheus metrics
§Features
inference- Enable automatic inference from message text. Adds the/v1/inferendpoint and allows the/v1/stateendpoint to accept amessagefield for automatic axis inference.
§Example
ⓘ
use attuned_http::{Server, ServerConfig};
use attuned_store::MemoryStore;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let store = MemoryStore::default();
let config = ServerConfig::default();
let server = Server::new(store, config);
server.run().await?;
Ok(())
}§With Inference
ⓘ
use attuned_http::{Server, ServerConfig};
use attuned_store::MemoryStore;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let store = MemoryStore::default();
let config = ServerConfig::default().with_inference();
let server = Server::new(store, config);
server.run().await?;
Ok(())
}Re-exports§
pub use handlers::AppState;pub use middleware::AuthConfig;pub use middleware::RateLimitConfig;pub use middleware::RateLimitKey;
Modules§
- handlers
- HTTP request handlers.
- middleware
- HTTP middleware for security, rate limiting, and authentication.
Structs§
- Server
- HTTP server for the Attuned API.
- Server
Config - Configuration for the HTTP server.
Enums§
- Http
Error - HTTP server errors.