pub struct Client { /* private fields */ }Expand description
Shared settings for outbound requests.
Implementations§
Source§impl Client
impl Client
pub fn new() -> Self
pub fn timeout(self, timeout: Duration) -> Self
Sourcepub fn retries(self, retries: u32) -> Self
pub fn retries(self, retries: u32) -> Self
Retry connection failures and timeouts, with exponential backoff.
Only transport failures are retried; a 500 is not, because the request may already have had an effect on the server.
Sourcepub fn breaker(self, breaker: CircuitBreaker) -> Self
pub fn breaker(self, breaker: CircuitBreaker) -> Self
Stop calling a host that is failing, and probe it before resuming.
Pass one breaker to every client that shares an upstream, so what one
of them learns the others act on. See crate::breaker.
Sourcepub fn circuit(&self) -> Option<&CircuitBreaker>
pub fn circuit(&self) -> Option<&CircuitBreaker>
The breaker this client is using, to ask about a host’s state.
pub fn default_header(self, name: &str, value: impl Into<String>) -> Self
Sourcepub fn faking(self, fake: Fake) -> Self
pub fn faking(self, fake: Fake) -> Self
Answer from a script instead of the network, for tests.
This is Http::fake() — an application’s tests should never depend on
a third-party API being up.
pub fn fake(&self) -> Option<&Arc<Fake>>
pub fn request(&self, method: Method, url: impl Into<String>) -> RequestBuilder
pub fn get(&self, url: impl Into<String>) -> RequestBuilder
pub fn post(&self, url: impl Into<String>) -> RequestBuilder
pub fn put(&self, url: impl Into<String>) -> RequestBuilder
pub fn patch(&self, url: impl Into<String>) -> RequestBuilder
pub fn delete(&self, url: impl Into<String>) -> RequestBuilder
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Client
impl !UnwindSafe for Client
impl Freeze for Client
impl Send for Client
impl Sync for Client
impl Unpin for Client
impl UnsafeUnpin for Client
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more