Skip to content

Commit

Permalink
fix(core): no need to use map
Browse files Browse the repository at this point in the history
  • Loading branch information
fundon committed Dec 29, 2024
1 parent bb5332b commit 9a3bbb5
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions viz-core/src/response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,12 @@ pub trait ResponseExt: private::Sealed + Sized {
use bytes::{BufMut, BytesMut};

let mut buf = BytesMut::with_capacity(128).writer();
serde_json::to_writer(&mut buf, &body)
.map(|()| {
Response::with(
Full::new(buf.into_inner().freeze()),
mime::APPLICATION_JSON.as_ref(),
)
})
.map_err(crate::types::PayloadError::Json)
serde_json::to_writer(&mut buf, &body).map_err(crate::types::PayloadError::Json)?;

Ok(Response::with(
Full::new(buf.into_inner().freeze()),
mime::APPLICATION_JSON.as_ref(),
))
}

/// Responds to a stream.
Expand Down

0 comments on commit 9a3bbb5

Please sign in to comment.