We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 8956307 commit 7c53882Copy full SHA for 7c53882
src/router.rs
@@ -57,6 +57,17 @@ impl Router {
57
58
let safe_filename = safe_filename.unwrap();
59
let filepath = PathBuf::from(dir_path).join(safe_filename);
60
+ if !filepath.exists() {
61
+ let catch_all_route = Route::from_str("GET /*")?;
62
+ if let Some(catch_all_callback) = self.routes.get(&catch_all_route) {
63
+ return catch_all_callback(request);
64
+ } else {
65
+ return HttpResponseBuilder::new()
66
+ .set_status(HttpStatusCode::NotFound)
67
+ .build();
68
+ }
69
70
+
71
let mime_type = mime_guess::from_path(&filepath).first_or_octet_stream();
72
let content = fs::read(filepath)?;
73
0 commit comments