From e3a7c5329e8917dc6fb6186ee8b19466a3d48669 Mon Sep 17 00:00:00 2001 From: neri Date: Mon, 3 Aug 2020 01:12:42 +0200 Subject: [PATCH] apply formatter --- src/main.rs | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/src/main.rs b/src/main.rs index 08acb1f..72188bf 100644 --- a/src/main.rs +++ b/src/main.rs @@ -4,7 +4,13 @@ mod multipart; use actix_files::{Files, NamedFile}; use actix_multipart::Multipart; -use actix_web::{error, http::header::{ContentDisposition, DispositionParam, DispositionType}, middleware, web::{self, Bytes}, App, Error, FromRequest, HttpRequest, HttpResponse, HttpServer}; +use actix_web::{ + error, + http::header::{ContentDisposition, DispositionParam, DispositionType}, + middleware, + web::{self, Bytes}, + App, Error, FromRequest, HttpRequest, HttpResponse, HttpServer, +}; use async_std::{ fs, path::PathBuf, @@ -75,8 +81,7 @@ async fn upload( async fn uploaded(id: web::Path, req: web::HttpRequest) -> Result { let url = req.url_for("file", &[id.as_str()])?; - let upload_html = UPLOAD_HTML - .replace("{url}", url.as_str()); + let upload_html = UPLOAD_HTML.replace("{url}", url.as_str()); Ok(HttpResponse::Ok() .content_type("text/html") .body(upload_html)) @@ -140,9 +145,13 @@ fn get_db_url() -> String { url += "@"; } - url += env::var("DATABASE_HOST").unwrap_or_else(|_| "localhost".to_string()).as_str(); + url += env::var("DATABASE_HOST") + .unwrap_or_else(|_| "localhost".to_string()) + .as_str(); url += "/"; - url += env::var("DATABASE_NAME").unwrap_or_else(|_| "datatrash".to_string()).as_str(); + url += env::var("DATABASE_NAME") + .unwrap_or_else(|_| "datatrash".to_string()) + .as_str(); url.to_string() }); @@ -215,7 +224,11 @@ async fn main() -> std::io::Result<()> { .service(web::resource("/").route(web::get().to(index))) .service(web::resource("/upload").route(web::post().to(upload))) .service(web::resource("/upload/{id}").route(web::get().to(uploaded))) - .service(web::resource("/file/{id}").name("file").route(web::get().to(download))) + .service( + web::resource("/file/{id}") + .name("file") + .route(web::get().to(download)), + ) .service(Files::new("/static", "static").disable_content_disposition()) } })