Module httper::client[][src]

HTTPer client

In order to start making http(s) requests you need to first initialize a HttperClient and then construct the http request with the method you want to use. For example for DELETE requests you call .delete() on the HttperClient instance and then you call .send() to send the request. See below for an example.

Example

 extern crate httper;
 extern crate tokio;
 #[macro_use]
 extern crate serde_derive;

 use httper::client::HttperClient;
 use tokio::runtime::Runtime;

 fn main() {
    let mut rt = Runtime::new().unwrap();

    let httper_client = HttperClient::new();

    #[derive(Debug, Deserialize)]
    struct Contributor {
        id: u32,
        login: String,
    }

    // Call .send() to fire the request and then call .json::<Vec<Contributor>>()
    // to turn the json response into a Vec containing Contributor.
    let result = rt.block_on(
        httper_client
            .get("https://api.github.com/repos/drager/httper/contributors")
            .send()
            .json::<Vec<Contributor>>(),
    );

    println!("Contributors: {:?}", result);
}

Modules

get
payload_builder
response_future

Structs

HttperClient

Type Definitions

Headers
HttpsClient