Trait HttpBuilderExt

Source
pub trait HttpBuilderExt: Sealed {
    // Required method
    fn header_typed<H: Header>(self, header: H) -> Self;
}
Expand description

An extension trait adding “typed” methods to http::request::Builder and http::response::Builder.

Required Methods§

Source

fn header_typed<H: Header>(self, header: H) -> Self

Add a typed Header to the builder.

This method is a convenience wrapper around headers::HeaderMapExt::typed_insert.

§Example for http::request::Builder
use thegraph_headers::HttpBuilderExt as _;

let request = http::request::Builder::new()
    .header_typed(ContentType::text())
    .body(())
    .expect("failed to build request");

assert!(request.headers().get("content-type").is_some());
§Example for http::response::Builder
use thegraph_headers::HttpBuilderExt as _;

let response = http::response::Builder::new()
    .header_typed(ContentType::text())
    .body(())
    .expect("failed to build response");

assert!(response.headers().get("content-type").is_some());

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl HttpBuilderExt for Builder

Source§

fn header_typed<H: Header>(self, header: H) -> Self

Source§

impl HttpBuilderExt for Builder

Source§

fn header_typed<H: Header>(self, header: H) -> Self

Implementors§