Skip to content

Commit

Permalink
Made the body collector more idomatic, dropped a match statement, now…
Browse files Browse the repository at this point in the history
… using unwrap_or_default().
  • Loading branch information
martinfrances107 committed Nov 23, 2023
1 parent cb6bdfb commit ae940ef
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
9 changes: 4 additions & 5 deletions integrations/axum/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,15 +161,14 @@ pub async fn generate_request_and_parts(
) -> (Request<Body>, RequestParts) {
// provide request headers as context in server scope
let (parts, body) = req.into_parts();
let body = match body
let body = body
.collect::<Vec<_>>()
.await
.into_iter()
.collect::<Result<Vec<Bytes>, _>>()
{
Ok(body) => body.concat().into(),
Err(_) => Bytes::default(),
};
.unwrap_or_default()
.concat()
.into();
let request_parts = RequestParts {
method: parts.method.clone(),
uri: parts.uri.clone(),
Expand Down
9 changes: 4 additions & 5 deletions integrations/viz/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,15 +107,14 @@ pub fn redirect(path: &str) {
pub async fn generate_request_parts(req: Request) -> RequestParts {
// provide request headers as context in server scope
let (parts, body) = req.into_parts();
let body = match body
let body = body
.collect::<Vec<_>>()
.await
.into_iter()
.collect::<Result<Vec<Bytes>, _>>()
{
Ok(body) => body.concat().into(),
Err(_) => Bytes::default(),
};
.unwrap_or_default()
.concat()
.into();

RequestParts {
method: parts.method,
Expand Down

0 comments on commit ae940ef

Please sign in to comment.