join-listeners #388
Answered
by
chrislearn
josejachuf
asked this question in
Q&A
-
Hi The same for multi-servers |
Beta Was this translation helpful? Give feedback.
Answered by
chrislearn
Aug 29, 2023
Replies: 1 comment
-
For example, if you want your server listener port 80 for http and port 443 for http2 and http3: use salvo::conn::rustls::{Keycert, RustlsConfig};
use salvo::prelude::*;
#[handler]
async fn hello() -> &'static str {
"Hello World"
}
#[tokio::main]
async fn main() {
tracing_subscriber::fmt().init();
let cert = include_bytes!("../certs/cert.pem").to_vec();
let key = include_bytes!("../certs/key.pem").to_vec();
let router = Router::new().get(hello);
let config = RustlsConfig::new(Keycert::new().cert(cert.as_slice()).key(key.as_slice()));
let listener = TcpListener::new(("127.0.0.1", 5800)).rustls(config.clone());
let acceptor = QuinnListener::new(config, ("127.0.0.1", 5800))
.join(listener)
.bind()
.await;
Server::new(acceptor).serve(router).await;
} |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
josejachuf
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For example, if you want your server listener port 80 for http and port 443 for http2 and http3: