touche 0.0.15

Synchronous HTTP library
Documentation
// Run with: curl --unix-socket examples/unix-socket.socket http://localhost
#[cfg(feature = "unix-sockets")]
fn main() -> std::io::Result<()> {
    use std::{fs, os::unix::net::UnixListener};
    use touche::{Response, Server, StatusCode};

    fs::remove_file("./examples/unix-socket.socket").ok();

    let listener = UnixListener::bind("./examples/unix-socket.socket")?;

    Server::builder()
        .max_threads(100)
        .from_connections(listener.incoming().filter_map(|conn| conn.ok()))
        .serve(|_req| {
            Response::builder()
                .status(StatusCode::OK)
                .body("Hello from Unix socket!")
        })
}

#[cfg(not(feature = "unix-sockets"))]
fn main() {
    println!("This example requires the unix-sockets feature to be enabled");
}