summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2020-05-22 11:34:55 +0200
committerMatthias Beyer <mail@beyermatthias.de>2020-05-22 11:34:55 +0200
commit49474dbbb5eb6e80728918480e20df47d74082e3 (patch)
treeea131b9fb8995301a400b312ecee5dffe8872819
parent256a241ea0f9cea4feed24783e8cf6c32f7daeb9 (diff)
Remove one call to unwrap()
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
-rw-r--r--src/main.rs18
1 files changed, 10 insertions, 8 deletions
diff --git a/src/main.rs b/src/main.rs
index c554119..cb66424 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -240,15 +240,17 @@ async fn on_put(req: Request<Body>) -> Result<Response<Body>, Infallible> {
};
let fileres = create_random_file(&CONFIG.data);
- if let Err(err) = fileres {
- error!("Failed to create random file: {}", err);
- return Ok(Response::builder()
- .status(500)
- .body(Body::from(ERR_500_HTML))
- .unwrap());
- }
+ let (mut file, name) = match fileres {
+ Ok(tpl) => tpl,
+ Err(err) => {
+ error!("Failed to create random file: {}", err);
+ return Ok(Response::builder()
+ .status(500)
+ .body(Body::from(ERR_500_HTML))
+ .unwrap());
+ },
+ };
- let (mut file, name) = fileres.unwrap();
info!("Created file '{}/{}'", CONFIG.data, name);
let mut reqbody = req.into_body();