aboutsummaryrefslogtreecommitdiff
path: root/examples/windmark.rs
diff options
context:
space:
mode:
authorFuwn <[email protected]>2023-04-04 09:33:14 +0000
committerFuwn <[email protected]>2023-04-04 09:33:14 +0000
commita6a61d5be2d508caf145e7d33fcbbd173fa8a356 (patch)
treeb2d1ffd50774960a6297bb88c999d5e9ea8a668f /examples/windmark.rs
parentfeat(route): native async route support !! (diff)
downloadwindmark-a6a61d5be2d508caf145e7d33fcbbd173fa8a356.tar.xz
windmark-a6a61d5be2d508caf145e7d33fcbbd173fa8a356.zip
feat(module): async module support
Diffstat (limited to 'examples/windmark.rs')
-rw-r--r--examples/windmark.rs11
1 files changed, 6 insertions, 5 deletions
diff --git a/examples/windmark.rs b/examples/windmark.rs
index 5ddf7a3..9c19cc3 100644
--- a/examples/windmark.rs
+++ b/examples/windmark.rs
@@ -33,12 +33,13 @@ struct Clicker {
clicks: isize,
}
-impl windmark::Module for Clicker {
- fn on_attach(&mut self, _: &mut Router) {
+#[async_trait::async_trait]
+impl windmark::AsyncModule for Clicker {
+ async fn on_attach(&mut self, _: &mut Router) {
println!("clicker has been attached!");
}
- fn on_pre_route(&mut self, context: HookContext<'_>) {
+ async fn on_pre_route(&mut self, context: HookContext<'_>) {
self.clicks += 1;
info!(
@@ -48,7 +49,7 @@ impl windmark::Module for Clicker {
);
}
- fn on_post_route(&mut self, context: HookContext<'_>) {
+ async fn on_post_route(&mut self, context: HookContext<'_>) {
info!(
"clicker has been called post-route on {} with {} clicks!",
context.url.path(),
@@ -78,7 +79,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
router.attach_stateless(|r| {
r.mount("/module", success!("This is a module!"));
});
- router.attach(Clicker::default());
+ router.attach_async(Clicker::default());
router.set_pre_route_callback(|context| {
info!(
"accepted connection from {} to {}",