1#![cfg_attr(docsrs, feature(doc_cfg))]
2#![doc = include_str!("../README.md")]
3#![warn(clippy::all, clippy::pedantic)]
4#![allow(clippy::missing_errors_doc, clippy::cast_precision_loss)]
5
6pub mod compression;
11pub mod json;
12pub mod middleware;
13mod server;
14pub mod wasm;
15
16pub use server::*;
17
18use time::format_description::BorrowedFormatItem;
19use time::macros::format_description;
20use tokio::signal;
21
22pub static GMT_FORMAT: &[BorrowedFormatItem<'static>] = format_description!(
23 "[weekday repr:short], [day] [month repr:short] [year] [hour]:[minute]:[second] GMT"
24);
25
26#[allow(clippy::missing_panics_doc)]
27pub async fn shutdown_signal() {
28 let ctrl_c = async {
29 signal::ctrl_c()
30 .await
31 .expect("failed to install Ctrl+C handler");
32 };
33
34 #[cfg(unix)]
35 let terminate = async {
36 signal::unix::signal(signal::unix::SignalKind::terminate())
37 .expect("failed to install signal handler")
38 .recv()
39 .await;
40 };
41
42 #[cfg(not(unix))]
43 let terminate = std::future::pending::<()>();
44
45 tokio::select! {
46 () = ctrl_c => {},
47 () = terminate => {},
48 }
49}