File tree Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,14 @@ use tokio::net::{TcpListener, TcpStream};
66mod tls_config;
77use tls_config:: tls_acceptor;
88
9+ /// An example of running an axum server with `TlsListener`.
10+ ///
11+ /// One can also bypass `axum::serve` and use the `Router` with Hyper's `serve_connection` API
12+ /// directly. The main advantages of using `axum::serve` are that
13+ /// - graceful shutdown is made easy with axum's `.with_graceful_shutdown` API, and
14+ /// - the Hyper server is configured by axum itself, allowing options specific to axum to be set
15+ /// (for example, axum currently enables the `CONNECT` protocol in order to support HTTP/2
16+ /// websockets).
917#[ tokio:: main( flavor = "current_thread" ) ]
1018async fn main ( ) {
1119 let app = Router :: new ( ) . route ( "/" , get ( || async { "Hello, World!" } ) ) ;
@@ -31,6 +39,8 @@ impl axum::serve::Listener for Listener {
3139 type Addr = SocketAddr ;
3240 async fn accept ( & mut self ) -> ( Self :: Io , Self :: Addr ) {
3341 loop {
42+ // To change the TLS certificate dynamically, you could `select!` on this call with a
43+ // channel receiver, and call `self.inner.replace_acceptor` in the other branch.
3444 match self . inner . accept ( ) . await {
3545 Ok ( tuple) => break tuple,
3646 Err ( tls_listener:: Error :: ListenerError ( e) ) if !is_connection_error ( & e) => {
You can’t perform that action at this time.
0 commit comments