Crate acton_htmx

Crate acton_htmx 

Source
Expand description

acton-htmx: Opinionated Rust web framework for HTMX applications

This framework builds on battle-tested components from the Acton ecosystem:

  • acton-service: Configuration, observability, middleware, connection pools
  • acton-reactive: Actor-based background jobs, sessions, and real-time features

§Design Principles

  1. Convention Over Configuration: Smart defaults everywhere
  2. Security by Default: CSRF, secure sessions, security headers enabled
  3. HTMX-First Architecture: Response helpers and patterns for hypermedia
  4. Type Safety Without Ceremony: Compile-time guarantees via Rust’s type system
  5. Idiomatic Excellence: Generated code exemplifies Rust best practices

§Quick Start

use acton_htmx::prelude::*;
use acton_reactive::prelude::ActonApp;

#[tokio::main]
async fn main() -> anyhow::Result<()> {
    // Launch the Acton runtime
    let mut runtime = ActonApp::launch();

    // Initialize application state (spawns session manager agent)
    let state = ActonHtmxState::new(&mut runtime).await?;

    // Build router with HTMX handlers and session middleware
    let app = axum::Router::new()
        .route("/", axum::routing::get(index))
        .layer(SessionLayer::new(&state))
        .with_state(state);

    // Start server
    let listener = tokio::net::TcpListener::bind("127.0.0.1:3000").await?;
    axum::serve(listener, app).await?;

    // Shutdown the agent runtime
    runtime.shutdown_all().await?;

    Ok(())
}

async fn index() -> &'static str {
    "Hello, HTMX!"
}

§Features

  • postgres - PostgreSQL database support (default)
  • sqlite - SQLite database support
  • mysql - MySQL database support
  • redis - Redis session and cache support (default)
  • otel-metrics - OpenTelemetry metrics collection

§Architecture

See the architecture overview for details.

Modules§

agents
acton-reactive agents
auth
Authentication and session management
config
Configuration management for acton-htmx
email
Email sending with multiple backends and template support
error
Error types and error handling
extractors
Axum extractors for acton-htmx
forms
Form handling, building, and validation for HTMX applications
handlers
HTTP handlers for acton-htmx
health
Health check endpoints and handlers
htmx
HTMX response types and extractors
jobs
Background job processing system using acton-reactive actors.
middleware
Middleware layers for acton-htmx
oauth2
OAuth2 authentication module
observability
Observability (logging, tracing, metrics)
prelude
Convenience re-exports for common types and traits
state
Application state management
storage
File storage abstraction and implementations
template
Askama template engine integration with HTMX patterns

Macros§

middleware_constructors
Helper macro for creating standard middleware layer constructors