A minimal and blazing-fast web framework for Rust, inspired by Express.js
express_rs aims to provide a clean, expressive, and flexible web framework modeled after the ergonomics of Express.js, but with the performance and safety guarantees of Rust.
The goal is to keep things simple, fast, and ergonomic — no macros, no ceremony — just modular, async-first routing, middlewares, and handler composition.
- Express-style routing with
.get(),.post(), etc. - Middleware system (
app.use(...)) with layered composition - Minimal
Apptype (no macro or derive required) - Request + Response types with mutable APIs
- Route parameter extraction (
/user/:id) - Route handler abstraction (
Handler) withNext - Logging with method, path and elapsed time
- Built-in response helpers (e.g.,
.send(),.json(),.status()) - File serving with streaming optimization + LRU cache
- MIME type detection (via [
mime_guess] and [infer]) - Route matching via fast radix tree (
matchthem) - Global string interner for path and param deduplication
- Type-safe per-request parameter access via extension API
- MethodKind enum + method bitflag support
- Internal
Appstruct with lazy router initialization -
Routertype with per-method route trees - Middleware pipeline with early return support
- Symbol-based interned parameters
- Static type-safe API for request extensions (
.locals, etc.) - Global
AppState<T>support like Actix - Built-in logging/tracing macros with levels
- Built-in
.envsupport for config (optional) - Pluggable middleware (logger, body-parser, etc.)
- Path prefix mounting (
app.use('/api', apiApp)) - Route grouping (
router.route('/users').get(...).post(...)) - Optional trailing slash handling
- Regex or wildcard segments (
*/.*)
- Benchmarks against Axum/Actix/Warp
- Zero-copy response body writing
- Avoid all heap allocations in hot path
- Smallvec for handler/index lists
use express_rs::App;
fn main() {
let mut app = App::default();
app.get("/", |req, res, _| {
res.send("Hello from Rust!");
});
app.listen(3000, || {
println!("🚀 Listening on http://localhost:3000");
});
}