http api client adjustment (#5953)
* missing feature lock for attempting to clone client * added helper macro to generate user agent without additional imports
This commit is contained in:
committed by
GitHub
parent
d95f66bd90
commit
979485c582
@@ -173,6 +173,10 @@ mod path;
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
pub use dns::{HickoryDnsError, HickoryDnsResolver};
|
||||
|
||||
// helper for generating user agent based on binary information
|
||||
#[doc(hidden)]
|
||||
pub use nym_bin_common::bin_info;
|
||||
|
||||
/// Default HTTP request connection timeout.
|
||||
///
|
||||
/// The timeout is relatively high as we are often making requests over the mixnet, where latency is
|
||||
@@ -608,6 +612,7 @@ impl Client {
|
||||
current_idx: Arc::new(Default::default()),
|
||||
reqwest_client: self.reqwest_client.clone(),
|
||||
|
||||
#[cfg(feature = "tunneling")]
|
||||
front: self.front.clone(),
|
||||
retry_limit: self.retry_limit,
|
||||
|
||||
|
||||
@@ -20,6 +20,16 @@ pub struct UserAgent {
|
||||
pub git_commit: String,
|
||||
}
|
||||
|
||||
/// Create `UserAgent` based on the caller's crate information
|
||||
// we can't use normal function as then `application` and `version` would correspond
|
||||
// of that of `nym-http-api-client` lib
|
||||
#[macro_export]
|
||||
macro_rules! generate_user_agent {
|
||||
() => {
|
||||
$crate::UserAgent::from($crate::bin_info!())
|
||||
};
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, thiserror::Error)]
|
||||
#[error("invalid user agent string: {0}")]
|
||||
pub struct UserAgentError(String);
|
||||
|
||||
Reference in New Issue
Block a user