diff options
| author | Fuwn <[email protected]> | 2022-03-26 04:16:14 +0000 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2022-03-26 04:16:14 +0000 |
| commit | 676e8968f92caf28c21f4e0a91db82a91ea9939c (patch) | |
| tree | e601a5b4814903453475bcf824812e4e6bae6c88 /examples | |
| parent | refactor(router): move default logger to logger feature (diff) | |
| download | windmark-676e8968f92caf28c21f4e0a91db82a91ea9939c.tar.xz windmark-676e8968f92caf28c21f4e0a91db82a91ea9939c.zip | |
feat: expose url to route
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/windmark.rs | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/examples/windmark.rs b/examples/windmark.rs index 847f2c3..378d0ad 100644 --- a/examples/windmark.rs +++ b/examples/windmark.rs @@ -24,30 +24,31 @@ fn main() -> std::io::Result<()> { .set_private_key_file("windmark_private.pem") .set_certificate_chain_file("windmark_pair.pem") .enable_default_logger(true) - .set_error_handler(|_| "error...".to_string()) - .set_pre_route_callback(|stream| { + .set_error_handler(|_, _| "error...".to_string()) + .set_pre_route_callback(|stream, url| { info!( - "accepted connection from {}", - stream.peer_addr().unwrap().ip() + "accepted connection from {} to {}", + stream.peer_addr().unwrap().ip(), + url.to_string() ) }) - .set_post_route_callback(|stream| { + .set_post_route_callback(|stream, _url| { info!( "closed connection from {}", stream.peer_addr().unwrap().ip() ) }) - .set_header(|_| "```\nART IS COOL\n```".to_string()) - .set_footer(|_| "Copyright 2022".to_string()) - .mount("/", |_| { + .set_header(|_, _| "```\nART IS COOL\n```".to_string()) + .set_footer(|_, _| "Copyright 2022".to_string()) + .mount("/", |_, _| { "# INDEX\n\nWelcome!\n\n=> /test Test Page\n=> /time Unix Epoch\n" .to_string() }) - .mount("/ip", |stream| { + .mount("/ip", |stream, _| { { format!("Hello, {}", stream.peer_addr().unwrap().ip()) }.into() }) - .mount("/test", |_| "hi there\n=> / back".to_string()) - .mount("/time", |_| { + .mount("/test", |_, _| "hi there\n=> / back".to_string()) + .mount("/time", |_, _| { std::time::UNIX_EPOCH .elapsed() .unwrap() |