🏗️ Elegant & Highly Performant Async Gemini Server Framework for the Modern Age
async framework gemini-protocol protocol gemini rust
at main 32 lines 913 B view raw
1//! `cargo run --example async --features response-macros` 2 3#[windmark::main] 4async fn main() -> Result<(), Box<dyn std::error::Error>> { 5 let mut router = windmark::router::Router::new(); 6 #[cfg(feature = "tokio")] 7 let async_clicks = std::sync::Arc::new(tokio::sync::Mutex::new(0)); 8 #[cfg(feature = "async-std")] 9 let async_clicks = std::sync::Arc::new(async_std::sync::Mutex::new(0)); 10 11 router.set_private_key_file("windmark_private.pem"); 12 router.set_certificate_file("windmark_public.pem"); 13 router.mount("/clicks", move |_| { 14 let async_clicks = async_clicks.clone(); 15 16 async move { 17 let mut clicks = async_clicks.lock().await; 18 19 *clicks += 1; 20 21 windmark::response::Response::success(*clicks) 22 } 23 }); 24 router.mount( 25 "/macro", 26 windmark::success_async!( 27 async { "This response was sent using an asynchronous macro." }.await 28 ), 29 ); 30 31 router.run().await 32}