🎯 Features
- Base on latest hyper, tokio;
- Websocket supported;
- Serve a static virtual directory from many physical directories;
- Middlewares support executed before or after handle;
- Easy routing:
- Path parameters and regex supported;
- Tree-like routing system;
⚡️ Quick start
You can view samples here or read docs here.
Create a new rust project:
Add this to Cargo.toml
[]
= "0.9"
= { = "1", = ["full"] }
Create a simple function handler in the main.rs file, we call it hello_world
, this function just render plain text "Hello World".
use *;
async
There are many ways to write function handler.
async
async
async
In the main
function, we need to create a root Router first, and then create a server and call it's bind
function:
use *;
async
async
Tree-like routing system
use *;
async
async
async
async
async
async
async
async
More Examples
Your can find more examples in examples folder:
- basic_auth.rs
- compression.rs
- file_list.rs
- proxy.rs
- remote_addr.rs
- routing.rs
- sse_chat.rs
- sse.rs
- tls.rs
- todos.rs
- unix_socket.rs
- ws_chat.rs
- ws.rs
☕ Supporters
Salvo is an open source project. If you want to support Salvo, you can ☕ buy a coffee here.
⚠️ License
Salvo is licensed under either of
- Apache License, Version 2.0, (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)