🏗️ Elegant & Highly Performant Async Gemini Server Framework for the Modern Age
async
framework
gemini-protocol
protocol
gemini
rust
1//! `cargo run --example callbacks`
2
3use windmark::context::HookContext;
4
5#[windmark::main]
6async fn main() -> Result<(), Box<dyn std::error::Error>> {
7 windmark::router::Router::new()
8 .set_private_key_file("windmark_private.pem")
9 .set_certificate_file("windmark_public.pem")
10 .mount("/", windmark::success!("Hello!"))
11 .set_pre_route_callback(|context: HookContext| {
12 println!(
13 "accepted connection from {} to {}",
14 context.peer_address.unwrap().ip(),
15 context.url.to_string()
16 )
17 })
18 .set_post_route_callback(
19 |context: HookContext, content: &mut windmark::response::Response| {
20 content.content = content.content.replace("Hello", "Hi");
21
22 println!(
23 "closed connection from {}",
24 context.peer_address.unwrap().ip()
25 )
26 },
27 )
28 .run()
29 .await
30}