cloudflare_but_works/framework/client/mod.rs
1use std::net::IpAddr;
2use std::time::Duration;
3
4pub mod async_api;
5// There is no blocking support for wasm.
6#[cfg(all(feature = "blocking", not(target_arch = "wasm32")))]
7pub mod blocking_api;
8
9/// Configuration for the API client. Allows users to customize its behaviour.
10pub struct ClientConfig {
11 /// The maximum time limit for an API request. If a request takes longer than this, it will be
12 /// cancelled.
13 /// Note: this configuration has no effect when the target is wasm32.
14 pub http_timeout: Duration,
15 /// A default set of HTTP headers which will be sent with each API request.
16 pub default_headers: http::HeaderMap,
17 /// A specific IP to use when establishing a connection
18 /// Note: this configuration has no effect when the target is wasm32.
19 pub resolve_ip: Option<IpAddr>,
20}
21
22impl Default for ClientConfig {
23 fn default() -> Self {
24 ClientConfig {
25 http_timeout: Duration::from_secs(30),
26 default_headers: http::HeaderMap::default(),
27 resolve_ip: None,
28 }
29 }
30}