Skip to content

Commit a24b69b

Browse files
Added ability to add catchall to root
1 parent 2534fe2 commit a24b69b

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/webserver/routing.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,17 @@ where
117117
{
118118
if path_and_query.path().ends_with(FORWARD_SLASH) {
119119
path.push(INDEX);
120-
find_file_or_not_found(&path, SQL_EXTENSION, store).await
120+
match find_file_or_not_found(&path, SQL_EXTENSION, store).await {
121+
Ok(NotFound) => {
122+
let target_sql = path.parent().unwrap_or_else(|| Path::new("/")).join("_.sql");
123+
if store.contains(&target_sql).await? {
124+
Ok(Execute(target_sql))
125+
} else {
126+
Ok(NotFound)
127+
}
128+
}
129+
result => result,
130+
}
121131
} else {
122132
let path_with_ext = path.with_extension(SQL_EXTENSION);
123133
match find_file(&path_with_ext, SQL_EXTENSION, store).await? {
@@ -156,9 +166,7 @@ where
156166
T: FileStore,
157167
{
158168
let mut parent = path.parent();
159-
debug!("Starting search for 404 or index file from: {}", path.display());
160169
while let Some(p) = parent {
161-
debug!("Checking parent path: {}", p.display());
162170
let target_404 = p.join(NOT_FOUND);
163171
if store.contains(&target_404).await? {
164172
return Ok(CustomNotFound(target_404));

0 commit comments

Comments
 (0)