-
Notifications
You must be signed in to change notification settings - Fork 4.2k
feat(injector): injector request formation changes #9306
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Changed Files
|
crates/injector/src/injector.rs
Outdated
let cert = reqwest::Certificate::from_pem(pem.as_bytes()).map_err(|e| { | ||
logger::error!("Failed to parse CA certificate PEM block: {}", e); | ||
error_stack::Report::new(InjectorError::HttpRequestFailed) | ||
})?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let cert = reqwest::Certificate::from_pem(pem.as_bytes()).map_err(|e| { | |
logger::error!("Failed to parse CA certificate PEM block: {}", e); | |
error_stack::Report::new(InjectorError::HttpRequestFailed) | |
})?; | |
let cert = reqwest::Certificate::from_pem(pem.as_bytes()).change_context(error_stack::Report::new(InjectorError::HttpRequestFailed)) | |
.inspect(|e| logger::error!("Failed to parse CA certificate PEM block: {}", e);)?; |
crates/injector/src/injector.rs
Outdated
.build() | ||
.change_context(HttpClientError::ClientConstructionFailed) | ||
.attach_printable("Failed to construct client with CA certificate"); | ||
return client_builder.use_rustls_tls().build().map_err(|e| { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here
crates/injector/src/injector.rs
Outdated
.attach_printable( | ||
"Failed to construct client with certificate and certificate key", | ||
); | ||
.map_err(|e| { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
change_context
crates/injector/src/injector.rs
Outdated
proxy_config: &Proxy, | ||
) -> error_stack::Result<reqwest::Client, InjectorError> { | ||
let client_builder = get_client_builder(proxy_config)?; | ||
client_builder.build().map_err(|e| { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
change_context
crates/injector/src/injector.rs
Outdated
@@ -561,66 +656,61 @@ pub mod core { | |||
"Certificate configuration applied" | |||
); | |||
|
|||
let request = request_builder.build(); | |||
let mut request = request_builder.build(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
instead of building a mutable request, populate all required fields in builder itself and call .build()
at the end
crates/injector/src/types.rs
Outdated
None | ||
} else { | ||
let mut headers_map = HashMap::new(); | ||
for (name, value) in header_map.iter() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use iter().map()
crates/injector/src/types.rs
Outdated
pub max_response_size: Option<usize>, | ||
} | ||
/// External vault metadata processing module | ||
pub mod vault_metadata { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
modules can be a separate files
const BASE64_ENGINE: base64::engine::GeneralPurpose = base64::engine::general_purpose::STANDARD; | ||
pub const EXTERNAL_VAULT_METADATA_HEADER: &str = "x-external-vault-metadata"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: move them to a common consts file
.attach_printable( | ||
"Failed to construct client with certificate and certificate key", | ||
); | ||
.change_context(InjectorError::HttpRequestFailed) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we unify the client builder to remove early returns?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
based on the condition only building the builder, otherwise need to create a mutable reference to the builder
73b0e20
Type of Change
Description
Request creation changes for injector to be used
InjectorRequest
struct creation.Also change the response type
Additional Changes
Motivation and Context
Making injector request and response more responsive and detailed from HTTP request
How did you test it?
Test cases which are present in the crate
Response
Response
Response
Response
Response
Response
Response
Response
Checklist
cargo +nightly fmt --all
cargo clippy