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"My post data...")
   .send()
   .await?;

let response = response.json().await?;
fn put(self, url: String) -> RequestBuilder

Construct a builder to PUT to the given url.

Examples

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

let response = client.put("https://postman-echo.com/put")
   .body_bytes(b"My put data...")
   .send()
   .await?;

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

Construct a builder to DELETE to the given url.

Examples

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

let response = client.delete("https://postman-echo.com/delete")
   .body_bytes(b"My delete data...")
   .send()
   .await?;

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

Construct a builder to HEAD to the given url.

Examples

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

let response = client.head("https://postman-echo.com/head")
   .body_bytes(b"My head data...")
   .send()
   .await?;

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