From 0bfd57be84b7cfe11e5181222ba6018e668d63c9 Mon Sep 17 00:00:00 2001 From: Fuwn Date: Mon, 3 Apr 2023 02:52:18 +0000 Subject: refactor(handler): move all responses to traits --- examples/windmark.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'examples') diff --git a/examples/windmark.rs b/examples/windmark.rs index afa6614..e10c343 100644 --- a/examples/windmark.rs +++ b/examples/windmark.rs @@ -77,14 +77,14 @@ async fn main() -> Result<(), Box> { r.mount("/module", success!("This is a module!")); }); router.attach(Clicker::default()); - router.set_pre_route_callback(Box::new(|context| { + 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(Box::new(|context, content| { + }); + router.set_post_route_callback(|context, content| { content.content = content.content.replace("Welcome!", "Welcome to Windmark!"); @@ -92,12 +92,12 @@ async fn main() -> Result<(), Box> { "closed connection from {}", context.tcp.peer_addr().unwrap().ip() ) - })); - router.add_header(Box::new(|_| "```\nART IS COOL\n```\nhi".to_string())); - router.add_footer(Box::new(|_| "Copyright 2022".to_string())); - router.add_footer(Box::new(|context| { + }); + router.add_header(|_| "```\nART IS COOL\n```\nhi".to_string()); + router.add_footer(|_| "Copyright 2022".to_string()); + router.add_footer(|context| { format!("Another footer, but lower! (from {})", context.url.path()) - })); + }); router.mount( "/", success!("# INDEX\n\nWelcome!\n\n=> /test Test Page\n=> /time Unix Epoch"), -- cgit v1.2.3