htmstd

Crates.iohtmstd
lib.rshtmstd
version0.7.0
created_at2025-11-21 15:43:52.908525+00
updated_at2025-11-21 15:43:52.908525+00
descriptionStandard Middleware Library for Starberry
homepage
repositoryhttps://github.com/Field-of-Dreams-Studio/hotaru
max_upload_size
id1943735
size75,309
(JerrySu5379)

documentation

README

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();

Cookie-Based Sessions

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

Commit count: 9

cargo fmt