style(format): reformat code with consistent line breaks and spacing

This commit is contained in:
zhenyi
2026-06-12 15:11:32 +08:00
parent 6f40921576
commit 0e13f90834
16 changed files with 381 additions and 347 deletions
+16 -16
View File
@@ -306,7 +306,10 @@ pub fn record_rate_limit_acquire(repo: &str) {
/// Record size distribution buckets (log2-based: 1KB, 4KB, 16KB, ..., 1GB).
fn record_size_bucket(map: &DashMap<String, AtomicU64>, label: &str, size: u64) {
let buckets = [1024, 4096, 16384, 65536, 262144, 1048576, 4194304, 16777216, 67108864, 268435456, 1073741824];
let buckets = [
1024, 4096, 16384, 65536, 262144, 1048576, 4194304, 16777216, 67108864, 268435456,
1073741824,
];
for &bound in &buckets {
let key = format!("{label}:le_{bound}");
if size <= bound {
@@ -558,20 +561,16 @@ impl Service<Request<Incoming>> for Router {
}
fn json_response(status: u16, body: &str) -> Response<Full<Bytes>> {
match Response::builder()
Response::builder()
.status(status)
.header("Content-Type", "application/json")
.header("Connection", "close")
.body(Full::new(Bytes::from(body.to_string())))
{
Ok(response) => response,
Err(err) => {
tracing::error!(error = %err, "failed to build JSON response");
Response::new(Full::new(Bytes::from_static(
br#"{"error":"response build failed"}"#,
)))
}
}
.body(Full::new(Bytes::from(body.to_string()))).unwrap_or_else(|err| {
tracing::error!(error = %err, "failed to build JSON response");
Response::new(Full::new(Bytes::from_static(
br#"{"error":"response build failed"}"#,
)))
})
}
fn text_response(status: u16, content_type: &str, body: String) -> Response<Full<Bytes>> {
@@ -579,10 +578,11 @@ fn text_response(status: u16, content_type: &str, body: String) -> Response<Full
.status(status)
.header("Content-Type", content_type)
.header("Connection", "close")
.body(Full::new(Bytes::from(body))).unwrap_or_else(|err| {
tracing::error!(error = %err, "failed to build text response");
Response::new(Full::new(Bytes::from_static(b"response build failed")))
})
.body(Full::new(Bytes::from(body)))
.unwrap_or_else(|err| {
tracing::error!(error = %err, "failed to build text response");
Response::new(Full::new(Bytes::from_static(b"response build failed")))
})
}
async fn handle_request(req: Request<Incoming>) -> Result<Response<Full<Bytes>>, Infallible> {