Struct ::http::Client

Overview

An asynchronous Client to make Requests with.

Methods

fn new() -> Client

Construct a new http client.

Examples

let client = http::Client::new();
fn get(self, url: String) -> RequestBuilder

Construct a builder to GET the given url.

Examples

let client = http::Client::new();

let response = client.get("http://example.com")
   .send()
   .await?;

let response = response.text().await?;

Construct a builder to POST to the given url.

Examples

let client = http::Client::new();

let response = client.post("https://postman-echo.com/post")
   .body_bytes(b"Hello World")
   .send()
   .await?;

let response = response.json().await?;