Skip to main content

secured_client_with_timeout

Function secured_client_with_timeout 

Source
pub fn secured_client_with_timeout(
    dns_port: u16,
    timeout: Duration,
) -> Result<Client>
Expand description

Creates a secured reqwest Client with timeout and DNS override.

This client uses the local DNS server for all DNS resolution and has a default timeout configured.

§Parameters

  • dns_port - The port of the local DNS server (obtained from mist::dns_port())
  • timeout - The timeout duration for requests

§Returns

Returns a configured reqwest::Client with DNS override and timeout.

§Example

use std::time::Duration;

use AirLibrary::HTTP::secured_client_with_timeout;
use Mist;

#[tokio::main]
async fn main() -> anyhow::Result<()> {
	let dns_port = mist::dns_port();
	let client = secured_client_with_timeout(dns_port, Duration::from_secs(30))?;

	// All HTTP requests will use the local DNS server with 30s timeout
	Ok(())
}