Debian Codegraph @

third_party/rust/warp/examples/tls.rs

raw
1 #![deny(warnings)]
2
3 // Don't copy this `cfg`, it's only needed because this file is within
4 // the warp repository.
5 // Instead, specify the "tls" feature in your warp dependency declaration.
6 #[cfg(feature = "tls")]
7 #[tokio::main]
8 async fn main() {
9 use warp::Filter;
10
11 // Match any request and return hello world!
12 let routes = warp::any().map(|| "Hello, World!");
13
14 warp::serve(routes)
15 .tls()
16 // RSA
17 .cert_path("examples/tls/cert.pem")
18 .key_path("examples/tls/key.rsa")
19 // ECC
20 // .cert_path("examples/tls/cert.ecc.pem")
21 // .key_path("examples/tls/key.ecc")
22 .run(([127, 0, 0, 1], 3030))
23 .await;
24 }
25
26 #[cfg(not(feature = "tls"))]
27 fn main() {
28 eprintln!("Requires the `tls` feature.");
29 }