-
Notifications
You must be signed in to change notification settings - Fork 19
Open
Description
Is your feature request related to a problem? Please describe.
We use an HTTP Proxy (squid) to connect to the internet.
In the LD SDKs for other languages, we only have to specify HTTP_PROXY=http://proxy.internal:8080 to tell the SDK to connect to the internet via the proxy. This isn't supported in Rust though
Describe the solution you'd like
When HTTP_PROXY is defined in the environment the LD client would use the proxy to connect to the ld backend
Current workaround
use hyper::client::HttpConnector;
use hyper_proxy::{Intercept, Proxy, ProxyConnector};
use launchdarkly_server_sdk::{
Client, ConfigBuilder, EventProcessorBuilder, ServiceEndpointsBuilder,
StreamingDataSourceBuilder,
};
pub use launchdarkly_server_sdk::{Context, ContextBuilder};
.....
let ld_config = if let Ok(http_proxy) = std::env::var("HTTP_PROXY") {
let proxy_uri = http_proxy.parse()?;
let proxy = Proxy::new(Intercept::All, proxy_uri);
let connector = HttpConnector::new();
let proxy_connector = ProxyConnector::from_proxy(connector, proxy).unwrap();
let mut data_source_builder = StreamingDataSourceBuilder::default();
data_source_builder.https_connector(proxy_connector.clone());
let mut event_processor_builder = EventProcessorBuilder::default();
event_processor_builder.https_connector(proxy_connector);
ConfigBuilder::new(&ld_sdk_key)
.event_processor(&event_processor_builder)
.data_source(&data_source_builder)
.build()
} else {
ConfigBuilder::new(&ld_sdk_key).build()
};gabriel-batistadelima
Metadata
Metadata
Assignees
Labels
No labels