Update to latest versions of hyper and http-body (#1882)

Co-authored-by: Michael Scofield <[email protected]>
Co-authored-by: Jonas Platte <[email protected]>
This commit is contained in:
David Pedersen
2023-11-23 11:03:03 +00:00
committed by GitHub
co-authored by Michael Scofield Jonas Platte
parent 2f4720907a
commit 43b14a5f02
93 changed files with 1463 additions and 1448 deletions
+46 -41
View File
@@ -5,51 +5,56 @@
//! kill or ctrl-c
//! ```
use axum::{response::Html, routing::get, Router};
use std::net::SocketAddr;
use tokio::signal;
#[tokio::main]
async fn main() {
// build our application with a route
let app = Router::new().route("/", get(handler));
// run it
let addr = SocketAddr::from(([127, 0, 0, 1], 3000));
println!("listening on {addr}");
hyper::Server::bind(&addr)
.serve(app.into_make_service())
.with_graceful_shutdown(shutdown_signal())
.await
.unwrap();
// TODO
fn main() {
eprint!("this example has not yet been updated to hyper 1.0");
}
async fn handler() -> Html<&'static str> {
Html("<h1>Hello, World!</h1>")
}
// use axum::{response::Html, routing::get, Router};
// use std::net::SocketAddr;
// use tokio::signal;
async fn shutdown_signal() {
let ctrl_c = async {
signal::ctrl_c()
.await
.expect("failed to install Ctrl+C handler");
};
// #[tokio::main]
// async fn main() {
// // build our application with a route
// let app = Router::new().route("/", get(handler));
#[cfg(unix)]
let terminate = async {
signal::unix::signal(signal::unix::SignalKind::terminate())
.expect("failed to install signal handler")
.recv()
.await;
};
// // run it
// let addr = SocketAddr::from(([127, 0, 0, 1], 3000));
// println!("listening on {}", addr);
// hyper::Server::bind(&addr)
// .serve(app.into_make_service())
// .with_graceful_shutdown(shutdown_signal())
// .await
// .unwrap();
// }
#[cfg(not(unix))]
let terminate = std::future::pending::<()>();
// async fn handler() -> Html<&'static str> {
// Html("<h1>Hello, World!</h1>")
// }
tokio::select! {
_ = ctrl_c => {},
_ = terminate => {},
}
// async fn shutdown_signal() {
// let ctrl_c = async {
// signal::ctrl_c()
// .await
// .expect("failed to install Ctrl+C handler");
// };
println!("signal received, starting graceful shutdown");
}
// #[cfg(unix)]
// let terminate = async {
// signal::unix::signal(signal::unix::SignalKind::terminate())
// .expect("failed to install signal handler")
// .recv()
// .await;
// };
// #[cfg(not(unix))]
// let terminate = std::future::pending::<()>();
// tokio::select! {
// _ = ctrl_c => {},
// _ = terminate => {},
// }
// println!("signal received, starting graceful shutdown");
// }