fix(middleware): early exit if next handler returned error
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user