Remove unwraps
This commit is contained in:
parent
dc216a80d5
commit
0132d32507
1 changed files with 17 additions and 17 deletions
|
@ -104,20 +104,21 @@ pub async fn hop(
|
||||||
};
|
};
|
||||||
|
|
||||||
match resolved_template {
|
match resolved_template {
|
||||||
Ok(HopAction::Redirect(path)) => Response::builder()
|
Ok(HopAction::Redirect(path)) => {
|
||||||
.status(StatusCode::FOUND)
|
let rendered = handlebars
|
||||||
.header(header::LOCATION, &path)
|
.render_template(
|
||||||
.body(boxed(Full::from(
|
&path,
|
||||||
handlebars
|
&template_args::query(utf8_percent_encode(
|
||||||
.render_template(
|
&args,
|
||||||
&path,
|
FRAGMENT_ENCODE_SET,
|
||||||
&template_args::query(utf8_percent_encode(
|
)),
|
||||||
&args,
|
)
|
||||||
FRAGMENT_ENCODE_SET,
|
.map_err(|_| StatusCode::INTERNAL_SERVER_ERROR)?;
|
||||||
)),
|
Response::builder()
|
||||||
)
|
.status(StatusCode::FOUND)
|
||||||
.unwrap(),
|
.header(header::LOCATION, &path)
|
||||||
))),
|
.body(boxed(Full::from(rendered)))
|
||||||
|
}
|
||||||
Ok(HopAction::Body(body)) => Response::builder()
|
Ok(HopAction::Body(body)) => Response::builder()
|
||||||
.status(StatusCode::OK)
|
.status(StatusCode::OK)
|
||||||
.body(boxed(Full::new(Bytes::from(body)))),
|
.body(boxed(Full::new(Bytes::from(body)))),
|
||||||
|
@ -128,13 +129,12 @@ pub async fn hop(
|
||||||
.body(boxed(Full::from("Something went wrong :(\n")))
|
.body(boxed(Full::from("Something went wrong :(\n")))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.unwrap()
|
|
||||||
}
|
}
|
||||||
RouteResolution::Unresolved => Response::builder()
|
RouteResolution::Unresolved => Response::builder()
|
||||||
.status(StatusCode::NOT_FOUND)
|
.status(StatusCode::NOT_FOUND)
|
||||||
.body(boxed(Full::from("not found\n")))
|
.body(boxed(Full::from("not found\n"))),
|
||||||
.unwrap(),
|
|
||||||
}
|
}
|
||||||
|
.map_err(|_| StatusCode::INTERNAL_SERVER_ERROR)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq)]
|
#[derive(Debug, PartialEq)]
|
||||||
|
|
Loading…
Reference in a new issue