1 unstable release

Uses new Rust 2024

0.7.0 Nov 21, 2025

#2777 in HTTP server


Used in sfx

GPL-3.0 license

605KB
10K SLoC

htmstd - Hotaru Standard Middleware Library

Crates.io MIT License

Standard middleware collection for the Hotaru web framework, providing common functionality like CORS, sessions, and authentication.

Middleware

CORS (Cross-Origin Resource Sharing)

Configure CORS policies for your application:

use htmstd::cors::AppCorsSettings;

let app = App::new()
    .set_config(
        AppCorsSettings::new()
            .allow_origin("https://example.com")
            .allow_methods(vec!["GET", "POST"])
    )
    .build();

Secure session management using encrypted cookies:

use htmstd::session::CookieSession;

let app = App::new()
    .append_middleware::<CookieSession>()
    .build();

Access session data in handlers:

endpoint! {
    APP.url("/login"),
    pub login<HTTP> {
        let mut session = ctx.get_session();
        session.set("user_id", "12345");
        text_response("Logged in")
    }
}

Safety Configuration

Configure HTTP safety limits per endpoint or globally:

use hotaru_core::http::HttpSafety;
use hotaru_core::http::HttpMethod;

endpoint! {
    APP.url("/api/upload"),
    config=[HttpSafety::new()
        .with_max_body_size(50 * 1024 * 1024)  // 50MB
        .with_allowed_methods(vec![HttpMethod::POST])
    ],
    pub upload<HTTP> {
        // Handle file upload
    }
}

Examples

For complete examples, see:

License

MIT License

Part of Hotaru Framework

This is the standard middleware library for the Hotaru web framework.

Learn more: https://fds.rs

Dependencies

~31–48MB
~854K SLoC