Skip to content

Commit 0446b34

Browse files
committed
add hello-world-hyper benchmark
1 parent a7360d2 commit 0446b34

File tree

3 files changed

+27
-0
lines changed

3 files changed

+27
-0
lines changed

benchmark/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@
33
members = [
44
"hello-world/actix-web",
55
"hello-world/axum",
6+
"hello-world/hyper",
67
]
+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[package]
2+
name = "hello-world-hyper"
3+
version = "0.1.0"
4+
edition = "2021"
5+
6+
[dependencies]
7+
hyper = { version = "0.14", features = ["full"] }
8+
tokio = { version = "1", features = ["full"] }
+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
use hyper::{
2+
service::{make_service_fn, service_fn},
3+
Body, Request, Response, Server,
4+
};
5+
use std::{convert::Infallible, net::SocketAddr};
6+
7+
#[tokio::main]
8+
async fn main() {
9+
let addr = SocketAddr::from(([127, 0, 0, 1], 3000));
10+
11+
let make_svc = make_service_fn(|_conn| async { Ok::<_, Infallible>(service_fn(hello_world)) });
12+
13+
Server::bind(&addr).serve(make_svc).await.unwrap();
14+
}
15+
16+
async fn hello_world(_req: Request<Body>) -> Result<Response<Body>, Infallible> {
17+
Ok(Response::new("Hello, World!".into()))
18+
}

0 commit comments

Comments
 (0)