Skip to content

Commit 382fada

Browse files
author
Devdutt Shenoi
committed
refactor: don't clone
1 parent b374183 commit 382fada

File tree

1 file changed

+6
-13
lines changed

1 file changed

+6
-13
lines changed

src/audit.rs

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,8 @@ use url::Url;
3939
static AUDIT_LOGGER: Lazy<Option<AuditLogger>> = Lazy::new(AuditLogger::new);
4040

4141
pub struct AuditLogger {
42-
client: Arc<Client>,
42+
client: Client,
4343
log_endpoint: Url,
44-
username: Option<String>,
45-
password: Option<String>,
4644
}
4745

4846
impl AuditLogger {
@@ -62,16 +60,9 @@ impl AuditLogger {
6260
}
6361
};
6462

65-
let client = Arc::new(reqwest::Client::new());
66-
67-
let username = CONFIG.parseable.audit_username.clone();
68-
let password = CONFIG.parseable.audit_password.clone();
69-
7063
Some(AuditLogger {
71-
client,
64+
client: reqwest::Client::new(),
7265
log_endpoint,
73-
username,
74-
password,
7566
})
7667
}
7768

@@ -81,8 +72,10 @@ impl AuditLogger {
8172
.post(self.log_endpoint.as_str())
8273
.json(&json)
8374
.header("x-p-stream", "audit_log");
84-
if let Some(username) = self.username.as_ref() {
85-
req = req.basic_auth(username, self.password.as_ref())
75+
76+
// Use basic auth if credentials are configured
77+
if let Some(username) = CONFIG.parseable.audit_username.as_ref() {
78+
req = req.basic_auth(username, CONFIG.parseable.audit_password.as_ref())
8679
}
8780

8881
match req.send().await {

0 commit comments

Comments
 (0)