Struct axum_server::tls::TlsServer [−][src]
pub struct TlsServer { /* fields omitted */ }
tls-rustls
only.Expand description
Configurable HTTP and HTTPS server, supporting HTTP/1.1 and HTTP2.
See module page for examples.
Implementations
pub fn bind<A, I>(self, addr: A) -> Self where
A: ToSocketAddrs<Iter = I> + Send + 'static,
I: Iterator<Item = SocketAddr> + 'static,
pub fn bind<A, I>(self, addr: A) -> Self where
A: ToSocketAddrs<Iter = I> + Send + 'static,
I: Iterator<Item = SocketAddr> + 'static,
Bind to a single address or multiple addresses.
Provide a Handle
.
Successive calls will overwrite last Handle
.
pub fn bind_rustls<A, I>(self, addr: A) -> Self where
A: ToSocketAddrs<Iter = I> + Send + 'static,
I: Iterator<Item = SocketAddr> + 'static,
pub fn bind_rustls<A, I>(self, addr: A) -> Self where
A: ToSocketAddrs<Iter = I> + Send + 'static,
I: Iterator<Item = SocketAddr> + 'static,
Bind to a single address or multiple addresses. Using tls protocol on streams.
Certificate and private key must be set before or after calling this.
Provide a loaded TlsLoader
.
This will overwrite any previously set private key and certificate(s) with its own ones.
Provide ServerConfig
containing private key and certificate(s).
When this value is set, other tls configurations are ignored.
Successive calls will overwrite last value.
Set private key in PEM format.
Successive calls will overwrite last private key.
Set certificate(s) in PEM format.
Successive calls will overwrite last certificate.
Set private key from file in PEM format.
Successive calls will overwrite last private key.
Set certificate(s) from file in PEM format.
Successive calls will overwrite last certificate.
Serve provided cloneable service on all binded addresses.
If accepting connection fails in any one of binded addresses, listening in all binded addresses will be stopped and then an error will be returned.
pub async fn serve_and_record<S, B>(self, service: S) -> Result<()> where
S: Service<Request<Body>, Response = Response<B>> + Send + Sync + 'static + Clone,
S::Error: Into<Box<dyn Error + Send + Sync>>,
S::Future: Send,
B: Body + Send + 'static,
B::Data: Send,
B::Error: Into<Box<dyn Error + Send + Sync>>,
This is supported on crate feature record
only.
pub async fn serve_and_record<S, B>(self, service: S) -> Result<()> where
S: Service<Request<Body>, Response = Response<B>> + Send + Sync + 'static + Clone,
S::Error: Into<Box<dyn Error + Send + Sync>>,
S::Future: Send,
B: Body + Send + 'static,
B::Data: Send,
B::Error: Into<Box<dyn Error + Send + Sync>>,
record
only.Serve provided cloneable service on all binded addresses.
Record sent and received bytes for each connection independently. Sent and
received bytes through a connection can be accessed through Request
extensions.
See axum_server::record
module for examples.
If accepting connection fails in any one of binded addresses, listening in all binded addresses will be stopped and then an error will be returned.