feat: API to search and list directories (#177)

use `?simple` to output path name only.
use `?json` to output paths in json format.
By default, output html page.

close #166
This commit is contained in:
sigoden
2023-02-20 11:05:53 +08:00
committed by GitHub
parent c6dcaf95d4
commit 7d6d7d49ca
10 changed files with 115 additions and 43 deletions

View File

@@ -44,7 +44,7 @@ pub fn tmpdir() -> TempDir {
for file in FILES {
tmpdir
.child(file)
.write_str(&format!("This is {}", file))
.write_str(&format!("This is {file}"))
.expect("Couldn't write to file");
}
for directory in DIRECTORIES {
@@ -59,8 +59,8 @@ pub fn tmpdir() -> TempDir {
continue;
}
tmpdir
.child(format!("{}{}", directory, file))
.write_str(&format!("This is {}{}", directory, file))
.child(format!("{directory}{file}"))
.write_str(&format!("This is {directory}{file}"))
.expect("Couldn't write to file");
}
}
@@ -109,11 +109,11 @@ where
pub fn wait_for_port(port: u16) {
let start_wait = Instant::now();
while !port_check::is_port_reachable(format!("localhost:{}", port)) {
while !port_check::is_port_reachable(format!("localhost:{port}")) {
sleep(Duration::from_millis(100));
if start_wait.elapsed().as_secs() > 1 {
panic!("timeout waiting for port {}", port);
panic!("timeout waiting for port {port}");
}
}
}