|
|
@ -4,7 +4,7 @@ use crate::{encode_uri, Args, BoxResult}; |
|
|
|
use async_walkdir::WalkDir; |
|
|
|
use async_walkdir::WalkDir; |
|
|
|
use async_zip::write::{EntryOptions, ZipFileWriter}; |
|
|
|
use async_zip::write::{EntryOptions, ZipFileWriter}; |
|
|
|
use async_zip::Compression; |
|
|
|
use async_zip::Compression; |
|
|
|
use chrono::{Local, TimeZone, Utc}; |
|
|
|
use chrono::{TimeZone, Utc}; |
|
|
|
use futures::stream::StreamExt; |
|
|
|
use futures::stream::StreamExt; |
|
|
|
use futures::TryStreamExt; |
|
|
|
use futures::TryStreamExt; |
|
|
|
use get_if_addrs::get_if_addrs; |
|
|
|
use get_if_addrs::get_if_addrs; |
|
|
@ -120,20 +120,16 @@ impl InnerService { |
|
|
|
let uri = req.uri().clone(); |
|
|
|
let uri = req.uri().clone(); |
|
|
|
let cors = self.args.cors; |
|
|
|
let cors = self.args.cors; |
|
|
|
|
|
|
|
|
|
|
|
let timestamp = Local::now().format("%d/%b/%Y %H:%M:%S"); |
|
|
|
|
|
|
|
let mut res = match self.handle(req).await { |
|
|
|
let mut res = match self.handle(req).await { |
|
|
|
Ok(res) => { |
|
|
|
Ok(res) => { |
|
|
|
println!(r#"[{}] "{} {}" - {}"#, timestamp, method, uri, res.status()); |
|
|
|
info!(r#""{} {}" - {}"#, method, uri, res.status()); |
|
|
|
res |
|
|
|
res |
|
|
|
} |
|
|
|
} |
|
|
|
Err(err) => { |
|
|
|
Err(err) => { |
|
|
|
let mut res = Response::default(); |
|
|
|
let mut res = Response::default(); |
|
|
|
let status = StatusCode::INTERNAL_SERVER_ERROR; |
|
|
|
let status = StatusCode::INTERNAL_SERVER_ERROR; |
|
|
|
status!(res, status); |
|
|
|
status!(res, status); |
|
|
|
eprintln!( |
|
|
|
error!(r#""{} {}" - {} {}"#, method, uri, status, err); |
|
|
|
r#"[{}] "{} {}" - {} {}"#, |
|
|
|
|
|
|
|
timestamp, method, uri, status, err |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
res |
|
|
|
res |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
@ -363,7 +359,7 @@ impl InnerService { |
|
|
|
let path = path.to_owned(); |
|
|
|
let path = path.to_owned(); |
|
|
|
tokio::spawn(async move { |
|
|
|
tokio::spawn(async move { |
|
|
|
if let Err(e) = zip_dir(&mut writer, &path).await { |
|
|
|
if let Err(e) = zip_dir(&mut writer, &path).await { |
|
|
|
eprintln!("Failed to zip {}, {}", path.display(), e); |
|
|
|
error!("Failed to zip {}, {}", path.display(), e); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
let stream = ReaderStream::new(reader); |
|
|
|
let stream = ReaderStream::new(reader); |
|
|
|