Skip to main content

HttpGetClient

Trait HttpGetClient 

Source
pub trait HttpGetClient: Sync {
    type Err: Error + Send + Sync + 'static;

    // Required method
    fn get(
        &self,
        url: &str,
    ) -> impl Future<Output = Result<Response, Self::Err>> + Send;
}
Expand description

Interface providing functionality of sending HTTP GET request. Motivation for introducing this abstraction is to allow an implementation of a more secure HTTP Client which could prevent malicious URL injections (e.g. by whitelisting hosts).

Required Associated Types§

Source

type Err: Error + Send + Sync + 'static

Error type used by this trait.

Required Methods§

Source

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

Performs a HTTP GET request with provided url.

Note: Return type of request is currently hardcoded. This is subject to change in the future.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§