From 3cb5f06c12b362e2f9ab8056c4343dbcae146b7f Mon Sep 17 00:00:00 2001 From: sigoden Date: Thu, 26 May 2022 20:14:18 +0800 Subject: [PATCH] style: cargo fmt --- Cargo.lock | 4 ++-- src/args.rs | 1 - src/server.rs | 12 ++++++++---- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 35cea9d..995bfb3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -329,9 +329,9 @@ checksum = "7709cef83f0c1f58f666e746a08b21e0085f7440fa6a29cc194d68aac97a4225" [[package]] name = "os_str_bytes" -version = "6.0.1" +version = "6.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "029d8d0b2f198229de29dca79676f2738ff952edf3fde542eb8bf94d8c21b435" +checksum = "21326818e99cfe6ce1e524c2a805c189a99b5ae555a35d19f9a284b427d86afa" [[package]] name = "percent-encoding" diff --git a/src/args.rs b/src/args.rs index 2448ae6..4fdeba8 100644 --- a/src/args.rs +++ b/src/args.rs @@ -34,7 +34,6 @@ fn app() -> clap::Command<'static> { .long("readonly") .help("Only serve static files, no operations like upload and delete"); - let arg_auth = Arg::new("auth") .short('a') .long("auth") diff --git a/src/server.rs b/src/server.rs index ff20147..f178207 100644 --- a/src/server.rs +++ b/src/server.rs @@ -62,8 +62,9 @@ impl InnerService { pub async fn handle(self: Arc, req: Request) -> Result { if !self.auth_guard(&req).unwrap_or_default() { let mut res = status_code!(StatusCode::UNAUTHORIZED); - res.headers_mut().insert("WWW-Authenticate" , HeaderValue::from_static("Basic")); - return Ok(res) + res.headers_mut() + .insert("WWW-Authenticate", HeaderValue::from_static("Basic")); + return Ok(res); } let res = if req.method() == Method::GET { @@ -136,7 +137,6 @@ impl InnerService { fs::remove_dir_all(path).await?; } Ok(status_code!(StatusCode::OK)) - } async fn handle_send_dir(&self, path: &Path) -> BoxResult { @@ -181,7 +181,11 @@ impl InnerService { paths.sort_unstable(); let breadcrumb = self.get_breadcrumb(path); - let data = SendDirData { breadcrumb, paths, readonly: self.args.readonly }; + let data = SendDirData { + breadcrumb, + paths, + readonly: self.args.readonly, + }; let data = serde_json::to_string(&data).unwrap(); let mut output =