Convert Infaliable Result into Option and handle
This commit is contained in:
parent
da45a503ac
commit
86f9b6fbb3
@ -29,11 +29,11 @@ cfg_if! { if #[cfg(feature = "ssr")] {
|
|||||||
let req = Request::builder().uri(uri.clone()).body(Body::empty()).unwrap();
|
let req = Request::builder().uri(uri.clone()).body(Body::empty()).unwrap();
|
||||||
// `ServeDir` implements `tower::Service` so we can call it with `tower::ServiceExt::oneshot`
|
// `ServeDir` implements `tower::Service` so we can call it with `tower::ServiceExt::oneshot`
|
||||||
// This path is relative to the cargo root
|
// This path is relative to the cargo root
|
||||||
match ServeDir::new(root).oneshot(req).await {
|
match ServeDir::new(root).oneshot(req).await.ok() {
|
||||||
Ok(res) => Ok(res.into_response()),
|
Some(res) => Ok(res.into_response()),
|
||||||
Err(err) => Err((
|
None => Err((
|
||||||
StatusCode::INTERNAL_SERVER_ERROR,
|
StatusCode::INTERNAL_SERVER_ERROR,
|
||||||
format!("Something went wrong: {err}"),
|
format!("Something went wrong"),
|
||||||
)),
|
)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user