diff options
| author | Fuwn <[email protected]> | 2023-04-06 07:38:27 +0000 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2023-04-06 07:38:27 +0000 |
| commit | 50601e3248865f4c4735ea44ae0ebd253be96397 (patch) | |
| tree | b3ce54c417a8996e51e6e92c7bbf2c85e4ca7c3d /examples | |
| parent | refactor(router): simplify context creation (diff) | |
| download | windmark-50601e3248865f4c4735ea44ae0ebd253be96397.tar.xz windmark-50601e3248865f4c4735ea44ae0ebd253be96397.zip | |
feat(context): bring back peer address
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/windmark.rs | 32 |
1 files changed, 16 insertions, 16 deletions
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<dyn std::error::Error>> { 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| { |