Skip to content

Commit

Permalink
chore: scaffold dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
0xAlcibiades committed Sep 10, 2024
1 parent b3e4255 commit cc0d0dc
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 1 deletion.
13 changes: 12 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,15 @@ readme = "README.md"
repository = "https://github.com/valorem-labs-inc/hyper-server"
version = "1.0.0"

[dependencies]
[dependencies]
http = "1.1.0"
http-body-util = "0.1.2"
hyper = "1.4.1"
hyper-util = { version = "0.1.8", features = ["server", "tokio", "server-auto", "server-graceful"] }
rustls = "0.23.13"
tokio = { version = "1.40.0", features = ["net"] }
tokio-rustls = "0.26.0"
tower = "0.5.1"

[dev-dependencies]
tokio = { version = "1.40.0", features = ["macros"] }
32 changes: 32 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Crate links:
// - tokio: https://docs.rs/tokio/latest/tokio/
// - rustls: https://docs.rs/rustls/latest/rustls/
// - tokio_rustls:https://docs.rs/tokio-rustls/latest/tokio_rustls/
// - hyper: https://docs.rs/hyper/latest/hyper/
// - tower: https://docs.rs/tower/latest/tower/

// We take a `SocketAddr` to bind the server to a specific address.
// We use `TcpListener` to bind the server to the specified address at the TCP layer.
// We use `rustls` to create a new `ServerConfig` instance.
// We use `tokio_rustls` to create a new `TlsAcceptor` instance.
// We use `hyper_util::server::conn::auto` to create a new `Connection` instance.
// Which then passes requests to a `hyper::service::Service` instance.
// Which then can optionally pass requests to a `tower::Service` instance.
// Behind that can be axum, tower, tonic,
// or any other service that implements the `tower::Service` trait.

pub struct HyperServer {}

#[cfg(test)]
mod tests {
use std::net::SocketAddr;
use tokio::net::TcpListener;

#[tokio::test]
async fn test_server() {
// Get a random port from the OS
let addr = SocketAddr::from(([127, 0, 0, 1], 0));
// Create a TCP listener bound to the random address
let listener = TcpListener::bind(&addr).await.unwrap();
}
}

0 comments on commit cc0d0dc

Please sign in to comment.