Crate attuned_http

Crate attuned_http 

Source
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 state
  • GET /v1/context/{user_id} - Get PromptContext
  • DELETE /v1/state/{user_id} - Delete state
  • POST /v1/infer - Infer axes from message text (requires “inference” feature)
  • GET /health - Health check
  • GET /metrics - Prometheus metrics

§Features

  • inference - Enable automatic inference from message text. Adds the /v1/infer endpoint and allows the /v1/state endpoint to accept a message field 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.
ServerConfig
Configuration for the HTTP server.

Enums§

HttpError
HTTP server errors.