Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Getting Started

TezWeb is a blazing-fast Rust HTTP framework built from scratch. No Hyper for HTTP/1.1, no Tower — just raw TCP and pure Rust.

Installation

Add TezWeb to your Cargo.toml:

[dependencies]
tezweb = { git = "https://github.com/akramjhabail/tezweb" }
tokio = { version = "1", features = ["full"] }

Hello World

use tezweb::{TezWeb, Response};

#[tokio::main]
async fn main() {
    TezWeb::new()
        .port(8080)
        .get("/hello", |_req, _params| async move {
            Response::ok().text("Hello from TezWeb! ⚡")
        })
        .run()
        .await
        .unwrap();
}

Run it:

cargo run

Visit http://localhost:8080/hello in your browser.

JSON Response

use tezweb::{TezWeb, Response};
use serde_json::json;

#[tokio::main]
async fn main() {
    TezWeb::new()
        .port(8080)
        .get("/users", |_req, _params| async move {
            Response::ok().json(&json!([
                {"id": 1, "name": "Akram"},
                {"id": 2, "name": "Ali"}
            ]))
        })
        .run()
        .await
        .unwrap();
}

Next Steps