HttpClientExt

Trait HttpClientExt 

Source
pub trait HttpClientExt: HttpClient {
    // Provided methods
    fn get(
        &self,
        url: &str,
    ) -> impl Future<Output = Result<Response<Bytes>>> + Send { ... }
    fn post_json<T: Serialize + Send + Sync>(
        &self,
        url: &str,
        body: &T,
    ) -> impl Future<Output = Result<Response<Bytes>>> + Send { ... }
    fn put_json<T: Serialize + Send + Sync>(
        &self,
        url: &str,
        body: &T,
    ) -> impl Future<Output = Result<Response<Bytes>>> + Send { ... }
    fn delete(
        &self,
        url: &str,
    ) -> impl Future<Output = Result<Response<Bytes>>> + Send { ... }
}
Expand description

Extension trait for HttpClient with convenience methods.

Provided Methods§

Source

fn get(&self, url: &str) -> impl Future<Output = Result<Response<Bytes>>> + Send

Execute a GET request.

§Errors

Returns an error if the request fails.

Source

fn post_json<T: Serialize + Send + Sync>( &self, url: &str, body: &T, ) -> impl Future<Output = Result<Response<Bytes>>> + Send

Execute a POST request with a JSON body.

§Errors

Returns an error if serialization or the request fails.

Source

fn put_json<T: Serialize + Send + Sync>( &self, url: &str, body: &T, ) -> impl Future<Output = Result<Response<Bytes>>> + Send

Execute a PUT request with a JSON body.

§Errors

Returns an error if serialization or the request fails.

Source

fn delete( &self, url: &str, ) -> impl Future<Output = Result<Response<Bytes>>> + Send

Execute a DELETE request.

§Errors

Returns an error if the request fails.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§