pub async fn serve_with<U: Upstream>(
listener: TcpListener,
service: ProxyService<U>,
options: ServeOptions,
) -> Result<()>Expand description
serve with options: TLS termination (mTLS when the config verifies
client certificates) and a cap on open connections. Each connection’s
service gets its peer, and behind TLS its client certificates, through
ProxyService::for_connection. The TLS handshake runs in the
connection’s own task, so a slow client does not hold up the others.
§Errors
See serve.
§Examples
use structured_proxy::{ProxyServer, ServeOptions};
let service = ProxyServer::from_yaml_str("service:\n name: demo\n")?
.service(tonic::service::Routes::default())?;
let listener = tokio::net::TcpListener::bind("0.0.0.0:8443").await?;
let options = ServeOptions::new().tls(tls).max_connections(10_000);
structured_proxy::serve_with(listener, service, options).await?;