1

as the title say,I want to write a https server,using hyper crate.

async fn runmain() {
    let addr = SocketAddr::from(([127, 0, 0, 1], 25025));

    let make_service = make_service_fn(|_conn| async {
        Ok::<_, hyper::Error>(service_fn(handle))
    });

    // Then bind and serve...
    // And run forever...
    if let Err(e) = Server::bind(&addr).serve(make_service).await {
        eprintln!("server error: {}", e);
    }

    println!("START!");
}

but it can only serve http request, the document does not show how to serve https, it just mentioned that you can use hyper_tls for client request,

Hunter
  • 43
  • 3
  • Hi Hunter. I took a quick look at the docs, then checked the GitHub project for this and came upon [this thread](https://github.com/hyperium/hyper-tls/issues/25). About half way down the thread, posters are saying they have managed to create a working server using these crates. I think you can find your answers there. The posts have links to source code. – Todd Sep 18 '21 at 07:14
  • Tks for the advice. I'll follow it. By the way, recently I just come out how to solve this problem. It's tokio's turn to handle tls connection by wrapping the tcp socket, and pass it to hyper, it's transparent from hyper side, and that's why hyper only care about http1 and http2, but no https – Hunter Sep 23 '21 at 07:39
  • Good job. I think you can post an answer to this question - unless SO requires more rep points first. – Todd Sep 23 '21 at 07:44

0 Answers0