aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFuwn <[email protected]>2024-07-17 00:42:59 +0000
committerFuwn <[email protected]>2024-07-17 01:38:22 +0000
commit91c880bb6384f3711926b7c5972a95c5e777a5e7 (patch)
treee928495faeec502f9cb5fbdcf5e5374532334324
parentfeat(router): setters for direct key and certificate content (diff)
downloadwindmark-0.3.11.tar.xz
windmark-0.3.11.zip
fix(router): ensure route-time locksv0.3.11
-rw-r--r--Cargo.toml2
-rw-r--r--src/router.rs38
2 files changed, 22 insertions, 18 deletions
diff --git a/Cargo.toml b/Cargo.toml
index e35ffb6..d6d55b2 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -5,7 +5,7 @@ members = ["rossweisse"]
[package]
name = "windmark"
-version = "0.3.10"
+version = "0.3.11"
authors = ["Fuwn <[email protected]>"]
edition = "2021"
description = "An elegant and highly performant async Gemini server framework"
diff --git a/src/router.rs b/src/router.rs
index eefbf83..efe47ef 100644
--- a/src/router.rs
+++ b/src/router.rs
@@ -433,14 +433,15 @@ impl Router {
module.on_pre_route(hook_context.clone()).await;
}
- for module in &mut *self.modules.lock().unwrap() {
- module.on_pre_route(hook_context.clone());
+ if let Ok(mut modules) = self.modules.lock() {
+ for module in &mut *modules {
+ module.on_pre_route(hook_context.clone());
+ }
}
- (*self.pre_route_callback)
- .lock()
- .unwrap()
- .call(hook_context.clone());
+ if let Ok(mut callback) = self.pre_route_callback.lock() {
+ callback.call(hook_context.clone());
+ }
let mut content = if let Ok(ref route) = route {
let footers_length = (*self.footers.lock().unwrap()).len();
@@ -451,11 +452,13 @@ impl Router {
peer_certificate,
);
- for partial_header in &mut *self.headers.lock().unwrap() {
- header.push_str(&format!(
- "{}\n",
- partial_header.call(route_context.clone()),
- ));
+ if let Ok(mut headers) = self.headers.lock() {
+ for partial_header in &mut *headers {
+ header.push_str(&format!(
+ "{}\n",
+ partial_header.call(route_context.clone()),
+ ));
+ }
}
for (i, partial_footer) in {
@@ -493,14 +496,15 @@ impl Router {
module.on_post_route(hook_context.clone()).await;
}
- for module in &mut *self.modules.lock().unwrap() {
- module.on_post_route(hook_context.clone());
+ if let Ok(mut modules) = self.modules.lock() {
+ for module in &mut *modules {
+ module.on_post_route(hook_context.clone());
+ }
}
- (*self.post_route_callback)
- .lock()
- .unwrap()
- .call(hook_context.clone(), &mut content);
+ if let Ok(mut callback) = self.post_route_callback.lock() {
+ callback.call(hook_context.clone(), &mut content);
+ }
stream
.write_all(