From 50601e3248865f4c4735ea44ae0ebd253be96397 Mon Sep 17 00:00:00 2001 From: Fuwn Date: Thu, 6 Apr 2023 07:38:27 +0000 Subject: feat(context): bring back peer address --- examples/windmark.rs | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) (limited to 'examples') diff --git a/examples/windmark.rs b/examples/windmark.rs index 687704d..0cdecd5 100644 --- a/examples/windmark.rs +++ b/examples/windmark.rs @@ -80,22 +80,22 @@ async fn main() -> Result<(), Box> { r.mount("/module", success!("This is a module!")); }); router.attach_async(Clicker::default()); - // router.set_pre_route_callback(|context| { - // info!( - // "accepted connection from {} to {}", - // context.tcp.peer_addr().unwrap().ip(), - // context.url.to_string() - // ) - // }); - // router.set_post_route_callback(|context, content| { - // content.content = - // content.content.replace("Welcome!", "Welcome to Windmark!"); - // - // info!( - // "closed connection from {}", - // context.tcp.peer_addr().unwrap().ip() - // ) - // }); + router.set_pre_route_callback(|context| { + info!( + "accepted connection from {} to {}", + context.peer_address.unwrap().ip(), + context.url.to_string() + ) + }); + router.set_post_route_callback(|context, content| { + content.content = + content.content.replace("Welcome!", "Welcome to Windmark!"); + + info!( + "closed connection from {}", + context.peer_address.unwrap().ip() + ) + }); router.add_header(|_| "```\nART IS COOL\n```\nhi".to_string()); router.add_footer(|_| "Copyright 2022".to_string()); router.add_footer(|context| { -- cgit v1.2.3