diff options
| author | Fuwn <[email protected]> | 2026-04-14 09:05:03 +0000 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2026-04-14 09:05:03 +0000 |
| commit | 92180ab10c5cd1394b3c288e4d730aa37c527629 (patch) | |
| tree | 17c1495e9724662206ef8c42091f972a0f2bc243 /examples | |
| parent | perf(router)!: Remove AsyncMutex from route and error handlers (diff) | |
| download | archived-windmark-92180ab10c5cd1394b3c288e4d730aa37c527629.tar.xz archived-windmark-92180ab10c5cd1394b3c288e4d730aa37c527629.zip | |
perf(router)!: Pass HookContext by reference to modules and hooks
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/async_stateful_module.rs | 4 | ||||
| -rw-r--r-- | examples/callbacks.rs | 4 | ||||
| -rw-r--r-- | examples/stateful_module.rs | 4 |
3 files changed, 6 insertions, 6 deletions
diff --git a/examples/async_stateful_module.rs b/examples/async_stateful_module.rs index 53d88be..6391611 100644 --- a/examples/async_stateful_module.rs +++ b/examples/async_stateful_module.rs @@ -13,7 +13,7 @@ impl windmark::module::AsyncModule for Clicker { println!("module 'clicker' has been attached!"); } - async fn on_pre_route(&mut self, context: HookContext) { + async fn on_pre_route(&mut self, context: &HookContext) { *self.clicks.lock().unwrap() += 1; println!( @@ -23,7 +23,7 @@ impl windmark::module::AsyncModule for Clicker { ); } - async fn on_post_route(&mut self, context: HookContext) { + async fn on_post_route(&mut self, context: &HookContext) { println!( "module 'clicker' clicker has been called after the route '{}' with {} \ clicks!", diff --git a/examples/callbacks.rs b/examples/callbacks.rs index 76014d5..e9b330d 100644 --- a/examples/callbacks.rs +++ b/examples/callbacks.rs @@ -8,7 +8,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> { .set_private_key_file("windmark_private.pem") .set_certificate_file("windmark_public.pem") .mount("/", windmark::success!("Hello!")) - .set_pre_route_callback(|context: HookContext| { + .set_pre_route_callback(|context: &HookContext| { println!( "accepted connection from {} to {}", context.peer_address.unwrap().ip(), @@ -16,7 +16,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> { ) }) .set_post_route_callback( - |context: HookContext, content: &mut windmark::response::Response| { + |context: &HookContext, content: &mut windmark::response::Response| { content.content = content.content.replace("Hello", "Hi"); println!( diff --git a/examples/stateful_module.rs b/examples/stateful_module.rs index 2ff698c..42c4ca1 100644 --- a/examples/stateful_module.rs +++ b/examples/stateful_module.rs @@ -12,7 +12,7 @@ impl windmark::module::Module for Clicker { println!("module 'clicker' has been attached!"); } - fn on_pre_route(&mut self, context: HookContext) { + fn on_pre_route(&mut self, context: &HookContext) { self.clicks += 1; println!( @@ -22,7 +22,7 @@ impl windmark::module::Module for Clicker { ); } - fn on_post_route(&mut self, context: HookContext) { + fn on_post_route(&mut self, context: &HookContext) { println!( "module 'clicker' clicker has been called after the route '{}' with {} \ clicks!", |