From e9c2a34defbc7930071f400dc285ee2572bc85e9 Mon Sep 17 00:00:00 2001 From: Thomas Lamprecht Date: Sat, 3 Jul 2021 20:49:16 +0200 Subject: [PATCH] REST: set error message extenesion for bad-request response log 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 (cherry picked from commit f4d371d2d2c5d79352e9681b5d942627e26c6fd4) Signed-off-by: Thomas Lamprecht --- src/server/rest.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/server/rest.rs b/src/server/rest.rs index 590f89ac..504bc278 100644 --- a/src/server/rest.rs +++ b/src/server/rest.rs @@ -253,7 +253,10 @@ impl tower_service::Service> 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();