Skip to content

Commit 8fdf85d

Browse files
authored
Add salvo web framework (#14)
* Add salvo web framework * version 0.25 * Update .gitignore
1 parent 10cbeef commit 8fdf85d

File tree

5 files changed

+34
-0
lines changed

5 files changed

+34
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ Respond "Hello, World!" to every request on "/" endpoint.
2323
- [ntex](benchmark/hello-world/ntex/src/main.rs)
2424
- [poem](benchmark/hello-world/poem/src/main.rs)
2525
- [rocket](benchmark/hello-world/rocket/src/main.rs)
26+
- [salvo](benchmark/hello-world/salvo/src/main.rs)
2627
- [thruster](benchmark/hello-world/thruster/src/main.rs)
2728
- [tide](benchmark/hello-world/tide/src/main.rs)
2829
- [warp](benchmark/hello-world/warp/src/main.rs)

benchmark/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ members = [
77
"hello-world/hyper",
88
"hello-world/ntex",
99
"hello-world/rocket",
10+
"hello-world/salvo",
1011
"hello-world/thruster",
1112
"hello-world/tide",
1213
"hello-world/warp",
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[package]
2+
name = "hello-world-salvo"
3+
version = "0.1.0"
4+
edition = "2021"
5+
6+
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
7+
8+
[dependencies]
9+
salvo = "0.25"
10+
tokio = { version = "1.12", features = ["rt-multi-thread", "macros"] }
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
use salvo::prelude::*;
2+
3+
#[fn_handler]
4+
fn hello() -> &'static str {
5+
"Hello, World!"
6+
}
7+
8+
#[tokio::main]
9+
async fn main() {
10+
let router = Router::new().get(hello);
11+
Server::new(TcpListener::bind("127.0.0.1:3000"))
12+
.serve(router)
13+
.await
14+
}

result/hello-world/hello-world.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ cargo build --release --bin hello-world-hyper
1010
cargo build --release --bin hello-world-ntex
1111
cargo build --release --bin hello-world-poem
1212
cargo +nightly build --release --bin hello-world-rocket
13+
cargo build --release --bin hello-world-salvo
1314
cargo build --release --bin hello-world-thruster
1415
cargo build --release --bin hello-world-tide
1516
cargo build --release --bin hello-world-warp
@@ -63,6 +64,13 @@ sleep 1
6364
eval $bench_cmd
6465
kill $!
6566

67+
# salvo
68+
echo "Salvo:"
69+
cargo run -q --release --bin hello-world-salvo &
70+
sleep 1
71+
eval $bench_cmd
72+
kill $!
73+
6674
# thruster
6775
echo "Thruster:"
6876
cargo run -q --release --bin hello-world-thruster &

0 commit comments

Comments
 (0)