axum-server
axum-server copied to clipboard
Serve same app on http and https
Hello,
thanks for developing this very useful crate!
I want to run a server that serves the same app with http and https on different ports.
I've seen there's an example for running different apps on http and https.
I could achieve this by running app.clone():
let a = axum_server::bind_rustls(
"0.0.0.0:8080".parse().unwrap(),
tls_config,
)
.handle(server_handle)
.serve(app.clone().into_make_service());
let b = axum_server::bind("0.0.0.0:8081".parse().unwrap()).serve(app.into_make_service());
select! {
_ = a => {},
_ = b => {}
}
However, this increased the memory usage of the server significantly. So I'm wondering if there is a better way to achieve this? Can someone maybe give me a hint?
I just measured the RAM usage again and found that my previous results were not accurate. The clone does not cost measurable more memory.
Duplicate of #48.