| Crates.io | bolt-web |
| lib.rs | bolt-web |
| version | 0.3.3 |
| created_at | 2025-10-15 21:25:46.860199+00 |
| updated_at | 2025-11-19 13:49:29.167587+00 |
| description | ⚡ A high-performance, minimalist web framework for Rust, inspired by Express.js and Gin. |
| homepage | https://bolt-web.com |
| repository | https://github.com/sumeeth05/boltweb |
| max_upload_size | |
| id | 1884977 |
| size | 113,081 |
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.
[dependencies]
bolt-web = "0.3"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1"
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" }));
}
Bolt offers a clean and expressive routing system.
Route macros like Get!, Post!, Put!, etc., automatically generate handler types.
Get!(app, "/hello", hello);
async fn hello(_req: &mut RequestBody, res: &mut ResponseWriter) {
res.send("Hello, world!");
}
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));
}
Get!(app, "/files/*path", get_file);
let page = req.query_param("page").unwrap_or("1".into());
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 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);
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")
);
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?;
Bolt includes multiple production-grade protections:
MIT © 2025 — Built with ❤️ in Rust.