From 768b5be9ffa55464d05a705a29bc317c3a996a31 Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Mon, 16 Mar 2026 18:23:43 -0700 Subject: [PATCH] Match Go pretty JSON 1-space indent and "Deletion Failed:" error prefix --- seaweed-volume/src/server/handlers.rs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/seaweed-volume/src/server/handlers.rs b/seaweed-volume/src/server/handlers.rs index 276764e78..1a423c076 100644 --- a/seaweed-volume/src/server/handlers.rs +++ b/seaweed-volume/src/server/handlers.rs @@ -2802,6 +2802,15 @@ fn build_disk_statuses(store: &crate::storage::store::Store) -> Vec(value: &T) -> String { + let mut buf = Vec::new(); + let formatter = serde_json::ser::PrettyFormatter::with_indent(b" "); + let mut ser = serde_json::Serializer::with_formatter(&mut buf, formatter); + value.serialize(&mut ser).unwrap(); + String::from_utf8(buf).unwrap() +} + fn json_response_with_params( status: StatusCode, body: &T, @@ -2816,7 +2825,7 @@ fn json_response_with_params( .cloned(); let json_body = if is_pretty { - serde_json::to_string_pretty(body).unwrap() + to_pretty_json_1space(body) } else { serde_json::to_string(body).unwrap() }; @@ -2860,7 +2869,7 @@ fn json_error_with_query( }; let json_body = if is_pretty { - serde_json::to_string_pretty(&body).unwrap() + to_pretty_json_1space(&body) } else { serde_json::to_string(&body).unwrap() };