slack-morphism-rust/examples/proxy_client.rs
Abdulla Abdurakhmanov aada464335
fix: Proxy example
2026-02-21 16:26:59 +01:00

30 lines
875 B
Rust

use slack_morphism::prelude::*;
use hyper_proxy2::{Intercept, Proxy, ProxyConnector};
async fn test_proxy_client() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
let proxy = {
let https_connector = hyper_rustls::HttpsConnectorBuilder::new()
.with_native_roots()?
.https_only()
.enable_http2()
.build();
let proxy_uri = "http://proxy.domain.unfortunate.world.example.net:3128"
.parse()
.unwrap();
let proxy = Proxy::new(Intercept::Https, proxy_uri);
ProxyConnector::from_proxy(https_connector, proxy).unwrap()
};
let _client = SlackClient::new(SlackClientHyperConnector::with_connector(proxy));
Ok(())
}
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
test_proxy_client().await?;
Ok(())
}