Skip to main content

HttpClient

Trait HttpClient 

Source
pub trait HttpClient: Send + Sync {
    // Required methods
    fn get_json(
        &self,
        url: &str,
        headers: &[(&str, String)],
    ) -> Result<Value, Box<dyn Error + Send + Sync>>;
    fn post_json(
        &self,
        url: &str,
        headers: &[(&str, String)],
        body: &Value,
    ) -> Result<Value, Box<dyn Error + Send + Sync>>;
}
Expand description

Minimal HTTP client interface for JSON POST/GET calls.

Required Methods§

Source

fn get_json( &self, url: &str, headers: &[(&str, String)], ) -> Result<Value, Box<dyn Error + Send + Sync>>

Perform a JSON GET request.

Source

fn post_json( &self, url: &str, headers: &[(&str, String)], body: &Value, ) -> Result<Value, Box<dyn Error + Send + Sync>>

Perform a JSON POST request.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§