]> git.proxmox.com Git - proxmox-backup.git/commitdiff
REST: set error message extenesion for bad-request response log
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Sat, 3 Jul 2021 18:49:16 +0000 (20:49 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Sat, 3 Jul 2021 19:34:03 +0000 (21:34 +0200)
We send it already to the user via the response body, but the
log_response does not has, nor wants to have FWIW, access to the
async body stream, so pass it through the ErrorMessageExtension
mechanism like we do else where.

Note that this is not only useful for PBS API proxy/daemon but also
the REST server of the file-restore daemon running inside the restore
VM, and it really is *very* helpful to debug things there..

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
src/server/rest.rs

index 2648217e91a388b9b912d420b2cff08dac8ac587..1145124769f04394398f027c4ead292090b1ac5c 100644 (file)
@@ -254,7 +254,10 @@ impl tower_service::Service<Request<Body>> for ApiService {
                         Some(apierr) => (apierr.message.clone(), apierr.code),
                         _ => (err.to_string(), StatusCode::BAD_REQUEST),
                     };
-                    Response::builder().status(code).body(err.into())?
+                    Response::builder()
+                        .status(code)
+                        .extension(ErrorMessageExtension(err.to_string()))
+                        .body(err.into())?
                 }
             };
             let logger = config.get_file_log();