src/api2/admin/datastore/h2upload.rs: avoid unwrap

This commit is contained in:
Dietmar Maurer 2019-05-08 08:21:18 +02:00
parent 4e3da4b366
commit 090ac9f79a
1 changed files with 8 additions and 10 deletions

View File

@ -183,15 +183,14 @@ fn upgrade_h2upload(
.select(abort_future.map_err(|_| {}).then(move |_| { bail!("task aborted"); }))
.and_then(|(result, _)| Ok(result))
.map_err(|(err, _)| err)
}).unwrap();
})?;
Ok(Box::new(futures::future::ok(
Response::builder()
let response = Response::builder()
.status(StatusCode::SWITCHING_PROTOCOLS)
.header(UPGRADE, HeaderValue::from_static(expected_protocol))
.body(Body::empty())
.unwrap()
)))
.body(Body::empty())?;
Ok(Box::new(futures::future::ok(response)))
}
fn backup_api() -> Router {
@ -248,8 +247,7 @@ fn test2_get(
println!("TASK DONE");
Ok(Response::builder()
.status(StatusCode::OK)
.body(Body::empty())
.unwrap())
.body(Body::empty())?)
});
Ok(Box::new(fut))