Skip to content

Commit 0242e3a

Browse files
committed
fix: add logs for tracing
1 parent d8abe85 commit 0242e3a

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ Should never be used in production for obvious reasons 💀
2626
- [ ] HTTPS 🛡️
2727
- [ ] Improved routing 🚄 (W.I.P)
2828
- [x] static file serving (using `mime_guess` for setting proper mime type)
29-
- [x] support for dynamic paths: `/foo/{:id}/bar`
29+
- [x] support for dynamic paths: `/foo/:id/bar`
3030

3131
## Usage example
3232

src/router.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,10 @@ impl Router {
6666
match selected_routes.len() {
6767
0 => Ok(None),
6868
1 => Ok(Some(selected_routes.first().unwrap())),
69-
_ => bail!("multiple selected routes is not possible"),
69+
_ => bail!(
70+
"multiple selected routes even though that should not happen: {:?}",
71+
selected_routes
72+
),
7073
}
7174
}
7275

@@ -82,8 +85,11 @@ impl Router {
8285
return callback(request, &routing_data);
8386
}
8487

88+
trace!("no matching server route, trying other options...");
89+
8590
// test against file server static mappings
8691
if let Some(file_server) = &self.file_server {
92+
trace!("attempting with file server");
8793
match file_server.handle_file_access(&route.path) {
8894
Ok(file_path) => {
8995
let mime_type = mime_guess::from_path(&file_path).first_or_octet_stream();
@@ -94,15 +100,17 @@ impl Router {
94100
.set_content_type(mime_type.as_ref())
95101
.build();
96102
}
97-
Err(e) => warn!("failed to match file: {e}"),
103+
Err(e) => trace!("no match with file server: {e}"),
98104
}
99105
}
100106

101107
// test against catcher routes
102108
if let Some(catcher) = self.catcher_routes.get(&request.method) {
109+
trace!("defaulting to catcher for {}", request.method.to_string());
103110
return catcher(request, &RoutingData::default());
104111
}
105112

113+
trace!("no default catcher, return 404");
106114
HttpResponseBuilder::new()
107115
.set_status(HttpStatusCode::NotFound)
108116
.build()

0 commit comments

Comments
 (0)