viz 0.2.3

Fast, flexible, minimalist web framework for Rust
Documentation

🦀 Features

  • Safety #![forbid(unsafe_code)]

  • Lightweight

  • Robust Routing

  • Flexible + Simple Handler & Middleware

  • Easy use Extractors

Example

use std::net::SocketAddr;
use viz::{get, Body, Request, Result, Router, Server, ServiceMaker};

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

#[tokio::main]
async fn main() -> Result<()> {
    let addr = SocketAddr::from(([127, 0, 0, 1], 3000));
    println!("listening on {}", addr);

    let app = Router::new().route("/", get(index));

    if let Err(err) = Server::bind(&addr)
        .tcp_nodelay(true)
        .serve(ServiceMaker::from(app))
        .await
    {
        println!("{}", err);
    }

    Ok(())
}

License

Licensed under either of Apache License, Version 2.0 or MIT license at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in Viz by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.