85 releases (2 stable)
Uses new Rust 2024
| 2.0.0-rc.52 | Sep 26, 2025 |
|---|---|
| 2.0.0-rc.32 | Apr 7, 2025 |
| 2.0.0-rc.29 | Mar 29, 2025 |
| 2.0.0-beta.7 | Nov 3, 2024 |
| 0.0.1 | Jun 6, 2024 |
#105 in HTTP server
2,221 downloads per month
175KB
4K
SLoC
Via
Welcome to Via, an asynchronous web framework for Rust, designed to be simple, flexible, and efficient. With Via, you can build fast and reliable web applications using familiar Rust patterns and modern async features.
Features
- Asynchronous: Built on top of
tokio, leveraging the full power of async programming in Rust. - Lightweight: Minimalistic API with no unnecessary abstractions or dependencies.
- Flexible Routing: Simple and intuitive path parameter handling.
- Customizable: Fine-grained control over requests, responses, and error handling.
Getting Started
Add the following to dependencies section of your Cargo.toml:
[dependencies]
via = "2.0.0-rc.52"
tokio = { version = "1", features = ["macros", "rt-multi-thread", "signal"] }
Hello World Example
Below is a basic example to demonstrate how to use Via to create a simple web server that responds to requests at /hello/:name with a personalized greeting.
use std::process::ExitCode;
use via::{App, BoxError, Next, Request, Response};
async fn hello(request: Request, _: Next) -> via::Result {
// Get a reference to the path parameter `name` from the request uri.
let name = request.param("name").percent_decode().into_result()?;
// Send a plain text response with our greeting message.
Response::build().text(format!("Hello, {}!", name))
}
#[tokio::main]
async fn main() -> Result<ExitCode, BoxError> {
let mut app = App::new(());
// Define a route that listens on /hello/:name.
app.at("/hello/:name").respond(via::get(hello));
via::serve(app).listen(("127.0.0.1", 8080)).await
}
Running the Example
To run this example, cd in to ./examples/hello-world, and then use cargo run:
cargo run
Visit http://localhost:8080/hello/world in your browser, and you should see the message "Hello, world!".
Documentation
For more detailed information on Via's features and how to use them, please refer to the official documentation. A link will be provided in this section once the crate is published.
Contributing
Contributions are welcome! Feel free to submit issues or pull requests on our GitHub repository.
Inspiration
This project is inspired by:
- Koa A web framework for Node.js.
- Tide The reference implementation of an async web server in Rust.
- Actix Web They paved their own way and I have so much respect for that.
- Rocket This project wouldn't exist if I hadn't tried to create Rocket with classes.
- warp Via is built on top of hyper. Without warp, Via wouldn't exist! Also, warp has the coolest API I've ever used to write a web server.
License
Licensed under either of
- Apache License, Version 2.0 (LICENSE-APACHE or https://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or https://opensource.org/licenses/MIT)
at your option.
Dependencies
~5–30MB
~566K SLoC