Update graceful shutdown example on type as well.

This commit is contained in:
Bittrance 2024-07-06 13:10:10 +02:00
parent 5c2ed13e84
commit 2a3a009c21
No known key found for this signature in database
GPG key ID: 8E33E27176953BDE

View file

@ -287,21 +287,22 @@ impl<M, S, F> WithGracefulShutdown<M, S, F> {
/// # Example
/// ```
/// use axum::{Router, routing::get};
/// use std::future::IntoFuture;
/// use tokio::sync::oneshot;
///
/// # async {
/// let router = Router::new().route("/", get(|| async { "Hello, World!" }));
///
/// let listener = tokio::net::TcpListener::bind("0.0.0.0:3000").await.unwrap();
/// axum::serve(listener, router)
/// .with_graceful_shutdown(shutdown_signal())
/// .tcp_nodelay(true)
/// .await
/// .unwrap();
/// let (tx, rx) = oneshot::channel();
/// tokio::spawn(
/// axum::serve(listener, router)
/// .with_graceful_shutdown(async move { rx.await.unwrap_or(()) })
/// .into_future(),
/// );
/// // ...
/// tx.send(()).unwrap();
/// # };
///
/// async fn shutdown_signal() {
/// // ...
/// }
/// ```
pub fn tcp_nodelay(self, nodelay: bool) -> Self {
Self {