| Crates.io | velto |
| lib.rs | velto |
| version | 1.9.0 |
| created_at | 2025-08-17 10:37:48.78262+00 |
| updated_at | 2025-10-26 20:42:19.243288+00 |
| description | Velto: expressive, async-native, and grounded Rust framework |
| homepage | |
| repository | https://github.com/pjdur/velto |
| max_upload_size | |
| id | 1799303 |
| size | 82,200 |
A minimal async web framework for Rust, built for clarity, speed, and joy.
route!(...) and route_any!(...) macrosrender!, {% include %}, and {% extends %} supportasync_tinyApp::use_middleware()velto::preludeTestRequestvelto-cliAdd Velto to your Cargo.toml:
[dependencies]
velto = "1.9.0"
Or use velto-cli to scaffold a new project instantly:
cargo install velto-cli
velto new my-app
cd my-app
velto run
use velto::prelude::*;
use velto::middleware::logger; // Built-in middleware
fn homepage(_req: &Request) -> Response {
render!("index.html", {
"title" => "Welcome to Velto",
"message" => "Fast. Clean. Rusty."
})
}
#[tokio::main]
async fn main() -> std::io::Result<()> {
let mut app = App::new();
app.use_middleware(logger); // Add middleware
app.enable_dev_mode(); // Enables LiveReload
route!(app, "/" => homepage);
app.serve_static("static");
app.run("127.0.0.1:8080").await
}
Velto supports global middleware functions that run before and/or after route handlers.
Use App::use_middleware() to register middleware like logging, authentication, or header injection.
pub fn logger(req: &Request, next: &dyn Fn(&Request) -> Response) -> Response {
println!("๐ฅ {} {}", req.method(), req.url());
let res = next(req);
println!("๐ค Responded with {}", res.status_code());
res
}
logger middleware is available in velto::middlewareVelto automatically watches your static/ and templates/ directories in dev mode.
When a file changes, connected browsers reload instantly via WebSocket.
No setup required. Just call:
app.enable_dev_mode();
Velto includes a built-in TestRequest type for simulating requests in unit tests:
#[test]
fn test_homepage() {
let mut app = App::new();
route!(app, "/" => |_req| {
Response::from_string("Hello, test!")
});
let res = velto::test::TestRequest::new("GET", "/").send(&app);
assert_eq!(res.status_code(), 200);
assert!(res.body().contains("Hello"));
}
No external test harness required โ just write Rust tests and run cargo test.
Velto is organized into modular components for clarity and maintainability:
velto/
โโโ src/
โ โโโ app.rs # Core application logic
โ โโโ dev.rs # Dev mode toggles and helpers
โ โโโ form.rs # Form data parsing
โ โโโ http_method.rs # HTTP method utilities
โ โโโ macros.rs # Macros for render! and route!
โ โโโ middleware.rs # Middleware system and built-in examples
โ โโโ prelude.rs # Public API surface
โ โโโ reload.rs # LiveReload WebSocket + file watcher
โ โโโ response.rs # HTTP response utilities including redirect helpers
โ โโโ router.rs # Routing and handler dispatch
โ โโโ template.rs # Templating engine with include/inheritance
โ โโโ test.rs # TestRequest and internal test harness
โ โโโ util.rs # Utility functions (e.g., MIME types)
โ โโโ lib.rs # Entry point
Velto is for developers who want:
Whether you're building a personal site, a microservice, or a dev tool, Velto gives you just enough structure to stay productive โ and just enough freedom to stay creative.
Velto 1.0.0 introduced async support and LiveReload, but kept the public API familiar. Here's what changed:
| Old (0.x) | New (1.0.0) |
|---|---|
fn main() |
#[tokio::main] async fn main() |
Response<Cursor<Vec<u8>>> |
Response (no generics) |
app.run(...) |
app.run(...).await |
| No LiveReload | app.enable_dev_mode() |
Most route handlers and macros (route!, render!) remain unchanged.
Just update your main() function and remove Cursor<Vec<u8>> from response types.
MIT โ free to use, modify, and distribute.
Velto is evolving rapidly. If you have ideas, feedback, or want to help shape its future, open an issue or submit a PR.
We welcome clean code, thoughtful design, and good vibes.