aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorFuwn <[email protected]>2023-04-06 07:25:24 +0000
committerFuwn <[email protected]>2023-04-06 07:25:24 +0000
commit4444f64ee98f314938a383b4dfdf3cd74fd7e717 (patch)
tree3c4f36a742112e0a0cde337aaa0ffe3fd7096a99 /examples
parentfeat(cargo): bump 0.3.0 -> 0.3.1 (diff)
downloadwindmark-4444f64ee98f314938a383b4dfdf3cd74fd7e717.tar.xz
windmark-4444f64ee98f314938a383b4dfdf3cd74fd7e717.zip
fix(context): fix async sharing
Diffstat (limited to 'examples')
-rw-r--r--examples/windmark.rs43
1 files changed, 18 insertions, 25 deletions
diff --git a/examples/windmark.rs b/examples/windmark.rs
index 7c46d9d..687704d 100644
--- a/examples/windmark.rs
+++ b/examples/windmark.rs
@@ -80,22 +80,22 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
r.mount("/module", success!("This is a module!"));
});
router.attach_async(Clicker::default());
- 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(|context, content| {
- content.content =
- content.content.replace("Welcome!", "Welcome to Windmark!");
-
- info!(
- "closed connection from {}",
- context.tcp.peer_addr().unwrap().ip()
- )
- });
+ // 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(|context, content| {
+ // content.content =
+ // content.content.replace("Welcome!", "Welcome to Windmark!");
+ //
+ // info!(
+ // "closed connection from {}",
+ // context.tcp.peer_addr().unwrap().ip()
+ // )
+ // });
router.add_header(|_| "```\nART IS COOL\n```\nhi".to_string());
router.add_footer(|_| "Copyright 2022".to_string());
router.add_footer(|context| {
@@ -110,13 +110,6 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
.with_mime("text/plain")
.clone()
});
- router.mount(
- "/ip",
- success!(
- context,
- format!("Hello, {}", context.tcp.peer_addr().unwrap().ip())
- ),
- );
router.mount("/test", success!("hi there\n=> / back"));
router.mount(
"/temporary-failure",
@@ -211,8 +204,8 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
Response::success(*clicks)
}
});
- router.mount("/async-nothing", |_| {
- async { Response::success("This is an async route.") }
+ router.mount("/async-nothing", |context| {
+ async move { Response::success(context.url.path()) }
});
router.mount(
"/async-macro",