mini-static 0.6.3

A secure, async static file server with streaming, traversal protection, and connection limits.
Documentation
use mini_static::Server;
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 = env::var("PORT")
        .unwrap_or_else(|_| "8080".to_string())
        .parse::<u16>()?;

    let root = env::var("ROOT").unwrap_or_else(|_| "./public".to_string());
    let root_path = Path::new(&root);

    let server = Server::new(root_path)?;

    // Bind to all interfaces (0.0.0.0) so the server is accessible from outside
    // (e.g., from the host when running in Docker)
    let (_port, handle) = server.run_all(port, Duration::from_secs(30)).await?;

    println!("mini-static listening on 0.0.0.0:{}", port);
    println!("serving files from: {}", root);

    // Keep the server running until interrupted
    tokio::signal::ctrl_c().await?;
    println!("shutting down...");
    handle.shutdown().await;

    Ok(())
}