Skip to content

Commit

Permalink
. code clean - Arc::as_ref for log_request
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremychone committed Nov 29, 2023
1 parent 61f6da4 commit 629a882
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
6 changes: 2 additions & 4 deletions crates/services/web-server/src/log/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,17 @@ use lib_core::ctx::Ctx;
use serde::Serialize;
use serde_json::{json, Value};
use serde_with::skip_serializing_none;
use std::sync::Arc;
use std::time::{SystemTime, UNIX_EPOCH};
use tracing::debug;
use uuid::Uuid;

// TODO: Need to cleanup the &Arc<.>
pub async fn log_request(
uuid: Uuid,
req_method: Method,
uri: Uri,
rpc_info: Option<&Arc<RpcInfo>>,
rpc_info: Option<&RpcInfo>,
ctx: Option<Ctx>,
web_error: Option<&Arc<web::Error>>,
web_error: Option<&web::Error>,
client_error: Option<ClientError>,
) -> Result<()> {
let timestamp = SystemTime::now()
Expand Down
5 changes: 2 additions & 3 deletions crates/services/web-server/src/web/mw_res_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,17 +52,16 @@ pub async fn mw_reponse_map(
// Build the new response from the client_error_body
(*status_code, Json(client_error_body)).into_response()
});

// -- Build and log the server log line.
let client_error = client_status_error.unzip().1;
// TODO: Need to hander if log_request fail (but should not fail request)
let _ = log_request(
uuid,
req_method,
uri,
rpc_info,
rpc_info.map(Arc::as_ref),
ctx,
web_error,
web_error.map(Arc::as_ref),
client_error,
)
.await;
Expand Down

0 comments on commit 629a882

Please sign in to comment.