From 2e77359c2f1cab769e34cde5c0dfb90a2d52b00b Mon Sep 17 00:00:00 2001 From: Stanisław Zagórowski Date: Fri, 19 Jan 2024 21:56:26 +0100 Subject: feature: add method and body to route params --- src/main.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'src/main.rs') diff --git a/src/main.rs b/src/main.rs index 881c0d3..64300fe 100644 --- a/src/main.rs +++ b/src/main.rs @@ -219,8 +219,7 @@ async fn serve_from_temp( tmp_dir.path().display().bright_blue() ); - // copy all files from the current directory to the temporary directory recursively. - let copied = recurse_copy(&change_dir, tmp_dir.path())?; + let copied = recurse_copy_lua(&change_dir, tmp_dir.path())?; println!("⏲️ {} files copied", copied.bright_green()); @@ -266,7 +265,7 @@ async fn serve(dev_mode: bool, port: u16, public_dir: Option) -> Result server::Server::serve(lua, port, public_dir).await } -fn recurse_copy(from: &Path, to: &Path) -> Result { +fn recurse_copy_lua(from: &Path, to: &Path) -> Result { let mut copied = 0; for entry in std::fs::read_dir(from)? { let entry = entry?; @@ -276,8 +275,12 @@ fn recurse_copy(from: &Path, to: &Path) -> Result { if path.is_dir() { std::fs::create_dir(&to)?; - copied += recurse_copy(&path, &to)?; + copied += recurse_copy_lua(&path, &to)?; } else { + let ext = path.extension().and_then(|s| s.to_str()); + if ext != Some("lua") && ext != Some("luax") { + continue; + } std::fs::copy(&path, &to)?; copied += 1; } -- cgit v1.3.1