#web-framework #http #web-server #server

bolt-web

⚡ A high-performance, minimalist web framework for Rust, inspired by Express.js and Gin

24 releases

Uses new Rust 2024

new 3.0.0 Nov 19, 2025
0.3.3 Nov 19, 2025
0.2.9 Nov 19, 2025
0.1.9 Oct 17, 2025

#424 in HTTP server

Download history 790/week @ 2025-10-14 38/week @ 2025-10-21 2/week @ 2025-10-28

109 downloads per month

MIT license

63KB
1.5K SLoC

⚡ Bolt-Web

A high-performance, minimalist web framework for Rust — inspired by Express.js and Gin.

Bolt is a lightweight, modular, and fully asynchronous web framework built on top of hyper and tokio. Its goal is performance, simplicity, and control — perfect for REST APIs, microservices, and backend systems.

🚀 Features

  • 🌐 HTTP/1.x & HTTP/2 Support — Built-in protocol selection.
  • 🚦 Fast Router — Path params, wildcards, and deterministic matching.
  • 🧩 Middleware System — CORS, Helmet, Logging, Rate-Limiting, and more.
  • 🔄 Async-First — Everything is async, from routing to middleware.
  • 👥 Route Groups — Clean organization for large APIs.
  • 🔒 Security Built-in — Panic protection, timeouts, connection limits, header/body limits.
  • 🌐 Minimal HTTP Client — Useful for internal service calls.

📦 Dependencies

[dependencies]
bolt-web = "0.3"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1"

🦀 Basic Example

use serde_json::json;

use bolt_web::{
    App,
    request::RequestBody,
    response::ResponseWriter,
    types::{BoltResult, Mode},
    Get,
};

#[bolt_web::main]
async fn main() -> BoltResult<()> {
    let mut app = App::new();

    Get!(app, "/hello", hello);

    app.run("127.0.0.1:8080", Mode::Http1, None).await?;
    Ok(())
}

async fn hello(_: &mut RequestBody, res: &mut ResponseWriter) {
    res.json(&json!({ "msg": "hello" }));
}

🧭 Routing

Bolt offers a clean and expressive routing system. Route macros like Get!, Post!, Put!, etc., automatically generate handler types.

Basic route

Get!(app, "/hello", hello);

async fn hello(_req: &mut RequestBody, res: &mut ResponseWriter) {
    res.send("Hello, world!");
}

Path Parameters

Get!(app, "/users/:id", get_user);

async fn get_user(req: &mut RequestBody, res: &mut ResponseWriter) {
    let id = req.param("id");
    res.send(&format!("User ID: {}", id));
}

Wildcard

Get!(app, "/files/*path", get_file);

Query Parameters

let page = req.query_param("page").unwrap_or("1".into());

🗂 Route Groups

let mut api = app.group("/api");

api.get("/status", status);
api.post("/login", login);

let mut v1 = api.group("/v1");
v1.get("/users", list_users);

Groups make large APIs clean and maintainable.

🔧 Middleware

Middleware can run before handlers and can short-circuit responses.

async fn log(req: &mut RequestBody, _res: &mut ResponseWriter) {
    println!("{} {}", req.method(), req.path());
}

Middleware!(app, "/", log);

🍪 Cookies

Bolt uses the cookie crate to generate RFC-compliant cookies.

res.cookie(
    "session", "abc123",
    Some(3600),         // 1 hour
    Some("/"),
    None,
    true,               // Secure
    true,               // HttpOnly
    Some("lax")
);

🌐 HTTP Client

Bolt includes a minimal async HTTP client for external APIs.

use bolt_web::Client;

let client = Client::new();

let joke: Joke = client.get("https://icanhazdadjoke.com", &None).await?;

🛡 Security

Bolt includes multiple production-grade protections:

  • Panic isolation
  • Request timeout
  • Read timeout (Slowloris protection)
  • Header limits
  • Body size limits
  • Connection limits
  • Graceful shutdown
  • TLS support

🧠 License

MIT © 2025 — Built with ❤️ in Rust.

Dependencies

~23–41MB
~774K SLoC