mini-static 0.33.2

A secure, async static file server with streaming, traversal protection, and connection limits.
Documentation
//! The plainest possible `mini-static` server, for `bench/throughput.sh`.
//!
//! No SPA mode, no live reload, no immutable-asset predicate — every one of those adds
//! per-request work, and a throughput baseline should measure the crate's floor rather
//! than one deployment's feature set. Single-threaded on purpose: the comparison against
//! nginx is one worker each, and a multi-threaded runtime would measure the machine.

use std::env;
use std::path::Path;
use std::time::Duration;

#[tokio::main(flavor = "current_thread")]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let port: u16 = env::var("PORT").unwrap_or_else(|_| "8081".into()).parse()?;
    let root = env::var("ROOT").unwrap_or_else(|_| "./bench/www".into());

    let server = mini_static::Server::new(Path::new(&root))?;
    let (bound, handle) = server
        .run_on(([127, 0, 0, 1], port).into(), Duration::from_secs(30))
        .await?;
    eprintln!("bench server on {bound}");

    tokio::signal::ctrl_c().await?;
    handle.shutdown().await;
    Ok(())
}