aboutsummaryrefslogtreecommitdiff
path: root/src
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 /src
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
Diffstat (limited to 'src')
-rw-r--r--src/router.rs38
1 files changed, 21 insertions, 17 deletions
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(