diff options
| author | Fuwn <[email protected]> | 2023-04-03 02:52:18 +0000 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2023-04-03 02:52:18 +0000 |
| commit | 0bfd57be84b7cfe11e5181222ba6018e668d63c9 (patch) | |
| tree | c9a8fec6a65718bf4504911c38942a3ce98698af /examples | |
| parent | refactor(handler): trait-based response (diff) | |
| download | windmark-0bfd57be84b7cfe11e5181222ba6018e668d63c9.tar.xz windmark-0bfd57be84b7cfe11e5181222ba6018e668d63c9.zip | |
refactor(handler): move all responses to traits
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/windmark.rs | 16 |
1 files changed, 8 insertions, 8 deletions
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<dyn std::error::Error>> { 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<dyn std::error::Error>> { "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"), |