diff options
author | Sven-Hendrik Haase <svenstaro@gmail.com> | 2020-03-11 18:27:10 +0000 |
---|---|---|
committer | Sven-Hendrik Haase <svenstaro@gmail.com> | 2020-03-11 18:27:10 +0000 |
commit | 27cb41d4ffece4867b23065a6602ed9b8843c418 (patch) | |
tree | 2053dcb3f49e3887edf9ade7eb07da7ecdc0bc65 /src | |
parent | Update CHANGELOG.md (diff) | |
download | miniserve-27cb41d4ffece4867b23065a6602ed9b8843c418.tar.gz miniserve-27cb41d4ffece4867b23065a6602ed9b8843c418.zip |
Format everything
Diffstat (limited to 'src')
-rw-r--r-- | src/args.rs | 4 | ||||
-rw-r--r-- | src/file_upload.rs | 12 | ||||
-rw-r--r-- | src/listing.rs | 11 | ||||
-rw-r--r-- | src/main.rs | 17 |
4 files changed, 23 insertions, 21 deletions
diff --git a/src/args.rs b/src/args.rs index 78340dd..49fe276 100644 --- a/src/args.rs +++ b/src/args.rs @@ -31,7 +31,7 @@ struct CLIArgs { /// /// Normally, when miniserve serves a directory, it creates a listing for that directory. /// However, if a directory contains this file, miniserve will serve that file instead. - #[structopt(long, parse(from_os_str), name="index_file")] + #[structopt(long, parse(from_os_str), name = "index_file")] index: Option<PathBuf>, /// Port to use @@ -83,7 +83,7 @@ struct CLIArgs { /// Enable overriding existing files during file upload #[structopt(short = "o", long = "overwrite-files")] overwrite_files: bool, - + /// Disable archive generation #[structopt(short = "r", long = "disable-archives")] disable_archives: bool, diff --git a/src/file_upload.rs b/src/file_upload.rs index af4fcf2..6e49f20 100644 --- a/src/file_upload.rs +++ b/src/file_upload.rs @@ -120,7 +120,7 @@ fn handle_multipart( pub fn upload_file( req: &HttpRequest<crate::MiniserveConfig>, default_color_scheme: ColorScheme, - uses_random_route: bool + uses_random_route: bool, ) -> FutureResponse<HttpResponse> { let return_path = if let Some(header) = req.headers().get(header::REFERER) { header.to_str().unwrap_or("/").to_owned() @@ -147,7 +147,7 @@ pub fn upload_file( query_params.order, color_scheme, default_color_scheme, - uses_random_route + uses_random_route, )); } }; @@ -167,7 +167,7 @@ pub fn upload_file( query_params.order, color_scheme, default_color_scheme, - uses_random_route + uses_random_route, )); } }; @@ -187,7 +187,7 @@ pub fn upload_file( query_params.order, color_scheme, default_color_scheme, - uses_random_route + uses_random_route, )); } }; @@ -212,7 +212,7 @@ pub fn upload_file( query_params.order, color_scheme, default_color_scheme, - uses_random_route + uses_random_route, ), }), ) @@ -228,7 +228,7 @@ fn create_error_response( sorting_order: Option<SortingOrder>, color_scheme: ColorScheme, default_color_scheme: ColorScheme, - uses_random_route: bool + uses_random_route: bool, ) -> FutureResult<HttpResponse, actix_web::error::Error> { errors::log_error_chain(description.to_string()); future::ok( diff --git a/src/listing.rs b/src/listing.rs index 256e062..d28824c 100644 --- a/src/listing.rs +++ b/src/listing.rs @@ -1,5 +1,5 @@ -use actix_web::{fs, Body, FromRequest, HttpRequest, HttpResponse, Query, Result}; use actix_web::http::StatusCode; +use actix_web::{fs, Body, FromRequest, HttpRequest, HttpResponse, Query, Result}; use bytesize::ByteSize; use futures::Stream; use htmlescape::encode_minimal as escape_html_entity; @@ -172,8 +172,7 @@ pub fn directory_listing<S>( Err(_) => continue, }; // show file url as relative to static path - let file_url = - utf8_percent_encode(&p.to_string_lossy(), FRAGMENT).to_string(); + let file_url = utf8_percent_encode(&p.to_string_lossy(), FRAGMENT).to_string(); // " -- " & -- & ' -- ' < -- < > -- > let file_name = escape_html_entity(&entry.file_name().to_string_lossy()); @@ -265,9 +264,9 @@ pub fn directory_listing<S>( default_color_scheme, false, false, - ).into_string() - ) - ); + ) + .into_string(), + )); } log::info!( "Creating an archive ({extension}) of {path}...", diff --git a/src/main.rs b/src/main.rs index 2885c59..a1ee303 100644 --- a/src/main.rs +++ b/src/main.rs @@ -62,7 +62,7 @@ pub struct MiniserveConfig { /// Enable upload to override existing files pub overwrite_files: bool, - + /// If false, creation of archives is disabled pub archives: bool, } @@ -142,8 +142,10 @@ fn run() -> Result<(), ContextualError> { if let Some(index_path) = &miniserve_config.index { let has_index: std::path::PathBuf = [&canon_path, index_path].iter().collect(); if !has_index.exists() { - - println!("{warning} The provided index file could not be found.", warning=Color::RGB(255, 192, 0).paint("Notice:").bold()); + println!( + "{warning} The provided index file could not be found.", + warning = Color::RGB(255, 192, 0).paint("Notice:").bold() + ); } } let path_string = canon_path.to_string_lossy(); @@ -266,7 +268,7 @@ fn configure_app(app: App<MiniserveConfig>) -> App<MiniserveConfig> { Some( fs::StaticFiles::new(path) .expect("Failed to setup static file handler") - .index_file(index_file.to_string_lossy()) + .index_file(index_file.to_string_lossy()), ) } else { let u_r = upload_route.clone(); @@ -283,7 +285,7 @@ fn configure_app(app: App<MiniserveConfig>) -> App<MiniserveConfig> { random_route.clone(), default_color_scheme, u_r.clone(), - archives_enabled + archives_enabled, ) }) .default_handler(error_404), @@ -300,8 +302,9 @@ fn configure_app(app: App<MiniserveConfig>) -> App<MiniserveConfig> { let default_color_scheme = app.state().default_color_scheme; // Allow file upload app.resource(&upload_route, move |r| { - r.method(Method::POST) - .f(move |file| file_upload::upload_file(file, default_color_scheme, uses_random_route)) + r.method(Method::POST).f(move |file| { + file_upload::upload_file(file, default_color_scheme, uses_random_route) + }) }) // Handle directories .handler(&full_route, s) |