Struct heroku_rs::framework::HttpApiClient[][src]

pub struct HttpApiClient { /* fields omitted */ }
Expand description

The client used to make requests to Heroku.

This struct contains the synchronous client.

Implementations

impl HttpApiClient[src]

pub fn create(token: &str) -> Fallible<HttpApiClient>[src]

Example 1:

Creating a simple client with the defaults. This has the production Heroku endpoint, 30 seconds timeout and the standard api key authentication.

use heroku_rs::prelude::*;

fn main() -> Result<(), Box<dyn std::error::Error>> {
   let api_client = HttpApiClient::create("API_KEY")?;

   // you can start making requests here

   Ok(())
}

pub fn new(
    credentials: Credentials,
    config: HttpApiClientConfig,
    environment: ApiEnvironment
) -> Fallible<HttpApiClient>
[src]

Example 2:

Creating a custom client in which you can specify the custom endpoint, timeouts and custom credentials.

This example is using a API key to authenticate, 10 second timeouts, and https://api.custom-somewhere.com/ base endpoint.

This is primarily used for testing / developement.

use heroku_rs::prelude::*;
use std::time::Duration;

fn main() -> Result<(), Box<dyn std::error::Error>> {
   let credentials = Credentials::UserAuthToken {
        token: String::from("API_KEY"),
   };

  let api_client = HttpApiClient::new(
   credentials,
   HttpApiClientConfig {
       http_timeout: Duration::from_secs(10),
       default_headers: http::HeaderMap::default(),
   },
   ApiEnvironment::Custom(url::Url::parse("https://api.custom-somewhere.com/").unwrap()))?;

   // you can start making requests here with api_client

   Ok(())
}

Trait Implementations

impl<'a> HerokuApiClient for HttpApiClient[src]

fn request<ResultType, QueryType, BodyType>(
    &self,
    endpoint: &dyn HerokuEndpoint<ResultType, QueryType, BodyType>
) -> ApiResponse<ResultType> where
    ResultType: ApiResult,
    QueryType: Serialize,
    BodyType: Serialize
[src]

Synchronously send a request to the Heroku API.

fn request_raw<ResultType, QueryType, BodyType>(
    &self,
    endpoint: &dyn HerokuEndpoint<ResultType, QueryType, BodyType>
) -> ApiResponse<Response> where
    ResultType: ApiResult,
    QueryType: Serialize,
    BodyType: Serialize
[src]

This returns a Result<reqwest::blocking::Response, heroku_rs::framework::response::error::HerokuApiFailure> Read more

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T> Instrument for T[src]

fn instrument(self, span: Span) -> Instrumented<Self>[src]

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

fn in_current_span(self) -> Instrumented<Self>[src]

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]

Performs the conversion.