Viz

Fast, robust, flexible, lightweight web framework for Rust

Safety! Docs.rs docs Crates.io version Download Discord

Note: viz's main branch is currently preparing breaking changes. For the most recently released code, look to the 0.4.x branch.

Features

Hello Viz

```rust use std::{net::SocketAddr, sync::Arc}; use tokio::net::TcpListener; use viz::{server::conn::http1, Request, Responder, Result, Router, Tree};

async fn index(_: Request) -> Result<&'static str> { Ok("Hello, Viz!") }

[tokio::main]

async fn main() -> Result<()> { let addr = SocketAddr::from(([127, 0, 0, 1], 3000)); let listener = TcpListener::bind(addr).await?; println!("listening on {addr}");

let app = Router::new().get("/", index);
let tree = Arc::new(Tree::from(app));

loop {
    let (stream, addr) = listener.accept().await?;
    let tree = tree.clone();
    tokio::task::spawn(async move {
        if let Err(err) = http1::Builder::new()
            .serve_connection(stream, Responder::new(tree, Some(addr)))
            .await
        {
            eprintln!("Error while serving HTTP connection: {err}");
        }
    });
}

} ```

More examples can be found here.

Get started

License

This project is licensed under the MIT license.

Author