Fix rustfmt

This commit is contained in:
Gregory Schier
2023-10-28 12:45:25 -07:00
parent 27dc261639
commit 82b185e27f
3 changed files with 17 additions and 10 deletions

1
rustfmt.toml Normal file
View File

@@ -0,0 +1 @@
edition = "2018"

View File

@@ -70,7 +70,8 @@ async fn send_ephemeral_request(
) -> Result<models::HttpResponse, String> { ) -> Result<models::HttpResponse, String> {
let pool = &*db_instance.lock().await; let pool = &*db_instance.lock().await;
let response = models::HttpResponse::default(); let response = models::HttpResponse::default();
return actually_send_ephemeral_request(request, &response, &environment_id, &app_handle, pool).await; return actually_send_ephemeral_request(request, &response, &environment_id, &app_handle, pool)
.await;
} }
async fn actually_send_ephemeral_request( async fn actually_send_ephemeral_request(
@@ -128,7 +129,7 @@ async fn actually_send_ephemeral_request(
continue; continue;
} }
}; };
headers.insert(header_name, header_value); headers.insert(header_name, header_value);
} }
@@ -137,12 +138,20 @@ async fn actually_send_ephemeral_request(
let a = request.authentication.0; let a = request.authentication.0;
if b == "basic" { if b == "basic" {
let raw_username = a.get("username").unwrap_or(empty_value).as_str().unwrap_or(""); let raw_username = a
let raw_password = a.get("password").unwrap_or(empty_value).as_str().unwrap_or(""); .get("username")
.unwrap_or(empty_value)
.as_str()
.unwrap_or("");
let raw_password = a
.get("password")
.unwrap_or(empty_value)
.as_str()
.unwrap_or("");
let username = render::render(raw_username, environment_ref); let username = render::render(raw_username, environment_ref);
let password = render::render(raw_password, environment_ref); let password = render::render(raw_password, environment_ref);
let auth = format!( "{username}:{password}"); let auth = format!("{username}:{password}");
let encoded = base64::engine::general_purpose::STANDARD_NO_PAD.encode(auth); let encoded = base64::engine::general_purpose::STANDARD_NO_PAD.encode(auth);
headers.insert( headers.insert(
"Authorization", "Authorization",
@@ -166,7 +175,7 @@ async fn actually_send_ephemeral_request(
(Some(raw_body), Some(_)) => { (Some(raw_body), Some(_)) => {
let body = render::render(&raw_body, environment_ref); let body = render::render(&raw_body, environment_ref);
builder.body(body).build() builder.body(body).build()
}, }
_ => builder.build(), _ => builder.build(),
}; };

View File

@@ -16,10 +16,7 @@ fn render_with_environment(template: &str, environment: &Environment) -> String
if !variable.enabled { if !variable.enabled {
continue; continue;
} }
map.insert( map.insert(variable.name.as_str(), variable.value.as_str());
variable.name.as_str(),
variable.value.as_str(),
);
} }
Regex::new(r"\$\{\[\s*([^]\s]+)\s*]}") Regex::new(r"\$\{\[\s*([^]\s]+)\s*]}")