Expand description
axum-server2 is a hyper server implementation designed to be used with axum framework.
§Features
- HTTP/1 and HTTP/2
- HTTPS through rustls or openssl.
- High performance through hyper.
- Using tower make service API.
- Very good axum compatibility. Likely to work with future axum releases.
§Guide
axum-server2 can serve items that implement MakeService with some additional trait
bounds. Make services that are created using axum
complies with those trait bounds out of the box. Therefore it is more convenient to use this
crate with axum.
All examples in this crate uses axum. If you want to use this crate without axum it is
highly recommended to learn how tower works.
Server::bind or bind function can be called to create a server that will bind to
provided SocketAddr when serve is called.
A Handle can be passed to Server for additional utilities like shutdown
and graceful shutdown.
bind_rustls can be called by providing RustlsConfig to create a HTTPS Server that
will bind on provided SocketAddr. RustlsConfig can be cloned, reload methods can be
used on clone to reload tls configuration.
§Features
§Example
A simple hello world application can be served like:
use axum::{routing::get, Router};
use std::net::SocketAddr;
#[tokio::main]
async fn main() {
let app = Router::new().route("/", get(|| async { "Hello, world!" }));
let addr = SocketAddr::from(([127, 0, 0, 1], 3000));
println!("listening on {}", addr);
axum_server2::bind(addr)
.serve(app.into_make_service())
.await
.unwrap();
}You can find more examples in repository.
Modules§
Accepttrait and utilities.- Service traits.
- tls_
boringssl tls-boringsslTls implementation usingopenssl - tls_
openssl tls-opensslTls implementation usingopenssl - tls_
rustls tls-rustlsTls implementation usingrustls.
Structs§
- A configuration for
AddrIncoming. - A handle for
Server. - A configuration for
Http. - HTTP server.
Functions§
- Create a
Serverthat will bind to provided address. - bind_
boringssl tls-boringsslCreate a TLS server that will be bound to the provided socket with a configuration. See thecrate::tls_opensslmodule for more details. - bind_
openssl tls-opensslCreate a TLS server that will be bound to the provided socket with a configuration. See thecrate::tls_opensslmodule for more details. - bind_
rustls tls-rustlsCreate a tls server that will bind to provided address. - Create a
Serverfrom existingstd::net::TcpListener. - from_
tcp_ rustls tls-rustlsCreate a tls server from existingstd::net::TcpListener.