From dd154be09e4ba14ba0e697f0995ec135c4088e75 Mon Sep 17 00:00:00 2001 From: boastful-squirrel Date: Fri, 16 Aug 2019 20:42:37 +0200 Subject: Do not 'back to listing' link when random route is set --- src/main.rs | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'src/main.rs') diff --git a/src/main.rs b/src/main.rs index dc98df0..b020333 100644 --- a/src/main.rs +++ b/src/main.rs @@ -257,6 +257,7 @@ fn configure_app(app: App) -> App { }; let random_route = app.state().random_route.clone().unwrap_or_default(); + let uses_random_route = app.state().random_route.clone().is_some(); let full_route = format!("/{}", random_route); if let Some(s) = s { @@ -265,7 +266,7 @@ fn configure_app(app: App) -> App { // Allow file upload app.resource(&upload_route, move |r| { r.method(Method::POST) - .f(move |file| file_upload::upload_file(file, default_color_scheme)) + .f(move |file| file_upload::upload_file(file, default_color_scheme, uses_random_route)) }) // Handle directories .handler(&full_route, s) @@ -285,11 +286,8 @@ fn configure_app(app: App) -> App { fn error_404(req: &HttpRequest) -> Result { let err_404 = ContextualError::RouteNotFoundError(req.path().to_string()); let default_color_scheme = req.state().default_color_scheme; - let return_address = match &req.state().random_route { - Some(random_route) => format!("/{}", random_route), - None => "/".to_string(), - }; - + let uses_random_route = req.state().random_route.is_some(); + let return_address = "/".to_string(); let query_params = listing::extract_query_parameters(req); let color_scheme = query_params.theme.unwrap_or(default_color_scheme); @@ -305,7 +303,7 @@ fn error_404(req: &HttpRequest) -> Result Date: Fri, 16 Aug 2019 20:55:26 +0200 Subject: Cleanup --- src/main.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/main.rs') diff --git a/src/main.rs b/src/main.rs index b020333..39dd9c0 100644 --- a/src/main.rs +++ b/src/main.rs @@ -287,7 +287,6 @@ fn error_404(req: &HttpRequest) -> Result) -> Result