1pub mod json;
6pub mod middleware;
7mod server;
8pub mod wasm;
9
10pub use server::*;
11
12use time::format_description;
13use time::format_description::BorrowedFormatItem;
14
15use tokio::signal;
16
17pub static GMT_FORMAT: std::sync::LazyLock<Vec<BorrowedFormatItem<'static>>> =
18 std::sync::LazyLock::new(|| {
19 format_description::parse(
20 "[weekday repr:short], [day] [month repr:short] [year] [hour]:[minute]:[second] GMT",
21 )
22 .expect("failed to create format")
23 });
24
25pub async fn shutdown_signal() {
26 let ctrl_c = async {
27 signal::ctrl_c()
28 .await
29 .expect("failed to install Ctrl+C handler");
30 };
31
32 #[cfg(unix)]
33 let terminate = async {
34 signal::unix::signal(signal::unix::SignalKind::terminate())
35 .expect("failed to install signal handler")
36 .recv()
37 .await;
38 };
39
40 #[cfg(not(unix))]
41 let terminate = std::future::pending::<()>();
42
43 tokio::select! {
44 _ = ctrl_c => {},
45 _ = terminate => {},
46 }
47}