Skip to content

Commit e668598

Browse files
authored
axum-extra: Add trailing newline to pretty JSON response (#3526)
1 parent 9bd839e commit e668598

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

axum-extra/src/response/erased_json.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,10 @@ impl ErasedJson {
5757
pub fn pretty<T: Serialize>(val: T) -> Self {
5858
let mut bytes = BytesMut::with_capacity(128);
5959
let result = match serde_json::to_writer_pretty((&mut bytes).writer(), &val) {
60-
Ok(()) => Ok(bytes.freeze()),
60+
Ok(()) => {
61+
bytes.put_u8(b'\n');
62+
Ok(bytes.freeze())
63+
}
6164
Err(e) => Err(Arc::new(e)),
6265
};
6366
Self(result)

0 commit comments

Comments
 (0)