fix(middleware): early exit if next handler returned error

This commit is contained in:
2025-12-13 22:25:42 +08:00
parent adf11ced6d
commit 611fdb556c

View File

@@ -57,6 +57,11 @@ pub async fn middleware(
let req = Request::from_parts(parts, axum::body::Body::from(processed_req.encrypted));
let res = next.run(req).await;
// Early exit if next handler returned error
if !res.status().is_success() {
return res;
}
// Process response: decrypt, deserialize, modify, re-encrypt
let (resp_parts, body) = res.into_parts();
let body_bytes;