RestClient

Trait RestClient 

Source
pub trait RestClient: Send + Sync {
    // Required methods
    fn get_request<'life0, 'async_trait>(
        &'life0 self,
        url: String,
        headers: Option<HashMap<String, String>>,
    ) -> Pin<Box<dyn Future<Output = Result<RestResponse, ServiceConnectivityError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn post_request<'life0, 'async_trait>(
        &'life0 self,
        url: String,
        headers: Option<HashMap<String, String>>,
        body: Option<String>,
    ) -> Pin<Box<dyn Future<Output = Result<RestResponse, ServiceConnectivityError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn delete_request<'life0, 'async_trait>(
        &'life0 self,
        url: String,
        headers: Option<HashMap<String, String>>,
        body: Option<String>,
    ) -> Pin<Box<dyn Future<Output = Result<RestResponse, ServiceConnectivityError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
}
Expand description

REST client trait for making HTTP requests.

This trait provides a way for users to supply their own HTTP client implementation for use with the SDK. The SDK will use this client for all HTTP operations including LNURL flows and chain service requests.

Required Methods§

Source

fn get_request<'life0, 'async_trait>( &'life0 self, url: String, headers: Option<HashMap<String, String>>, ) -> Pin<Box<dyn Future<Output = Result<RestResponse, ServiceConnectivityError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Makes a GET request and logs on DEBUG.

§Arguments
  • url: the URL on which GET will be called
  • headers: optional headers that will be set on the request
Source

fn post_request<'life0, 'async_trait>( &'life0 self, url: String, headers: Option<HashMap<String, String>>, body: Option<String>, ) -> Pin<Box<dyn Future<Output = Result<RestResponse, ServiceConnectivityError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Makes a POST request, and logs on DEBUG.

§Arguments
  • url: the URL on which POST will be called
  • headers: the optional POST headers
  • body: the optional POST body
Source

fn delete_request<'life0, 'async_trait>( &'life0 self, url: String, headers: Option<HashMap<String, String>>, body: Option<String>, ) -> Pin<Box<dyn Future<Output = Result<RestResponse, ServiceConnectivityError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Makes a DELETE request, and logs on DEBUG.

§Arguments
  • url: the URL on which DELETE will be called
  • headers: the optional DELETE headers
  • body: the optional DELETE body

Implementors§