Skip to main content

HttpBody

Type Alias HttpBody 

Source
pub type HttpBody = BoxBody<Bytes, BoxError>;
Expand description

HTTP request body type for crate::HttpClient.

Use http_body_util to construct bodies and call .map_err(…).boxed() to convert:

use apollo_http_client::HttpBody;
use bytes::Bytes;
use http_body_util::{BodyExt, Empty, Full};

// Empty body (e.g. for GET requests)
let _: HttpBody = Empty::<Bytes>::new()
    .map_err(|e: std::convert::Infallible| match e {})
    .boxed();

// Fixed-size body (e.g. for POST)
let _: HttpBody = Full::new(Bytes::from_static(b"hello"))
    .map_err(|e: std::convert::Infallible| match e {})
    .boxed();

Aliased Type§

pub struct HttpBody { /* private fields */ }