aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorFuwn <[email protected]>2023-04-06 07:38:27 +0000
committerFuwn <[email protected]>2023-04-06 07:38:27 +0000
commit50601e3248865f4c4735ea44ae0ebd253be96397 (patch)
treeb3ce54c417a8996e51e6e92c7bbf2c85e4ca7c3d /examples
parentrefactor(router): simplify context creation (diff)
downloadwindmark-50601e3248865f4c4735ea44ae0ebd253be96397.tar.xz
windmark-50601e3248865f4c4735ea44ae0ebd253be96397.zip
feat(context): bring back peer address
Diffstat (limited to 'examples')
-rw-r--r--examples/windmark.rs32
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| {