Crates.io | via |
lib.rs | via |
version | 2.0.0-rc.50 |
created_at | 2024-06-06 19:03:01.277412+00 |
updated_at | 2025-09-25 18:37:55.898069+00 |
description | An async multi-threaded web framework for people who appreciate simplicity. |
homepage | https://github.com/zacharygolba/via |
repository | https://github.com/zacharygolba/via |
max_upload_size | |
id | 1263996 |
size | 195,560 |
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.
tokio
, leveraging the full power of async programming in Rust.Add the following to dependencies section of your Cargo.toml
:
[dependencies]
via = "2.0.0-rc.50"
tokio = { version = "1", features = ["macros", "rt-multi-thread", "signal"] }
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
}
To run this example, cd
in to ./examples/hello-world
, and then use cargo run
:
cargo run
Visit http://127.0.0.1:8080/hello/world
in your browser, and you should see the message "Hello, world!".
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.
Contributions are welcome! Feel free to submit issues or pull requests on our GitHub repository.
This project is inspired by:
Licensed under either of
at your option.