Function bind_rustls

Source
pub fn bind_rustls(
    addr: SocketAddr,
    config: RustlsConfig,
) -> Server<RustlsAcceptor>
Available on crate feature tls-rustls only.
Expand description

Create a tls server that will bind to provided address.

Examples found in repository?
examples/rustls_server.rs (line 22)
10async fn main() {
11    let app = Router::new().route("/", get(|| async { "Hello, world!" }));
12
13    let config = RustlsConfig::from_pem_file(
14        "examples/self-signed-certs/cert.pem",
15        "examples/self-signed-certs/key.pem",
16    )
17    .await
18    .unwrap();
19
20    let addr = SocketAddr::from(([127, 0, 0, 1], 3000));
21    println!("listening on {}", addr);
22    hyper_serve::tls_rustls::bind_rustls(addr, config)
23        .serve(app.into_make_service())
24        .await
25        .unwrap();
26}