Skip to main content

Module negotiate

Module negotiate 

Source
Available on crate features client and client-pool only.
Expand description

Negotiate a pool of services

The negotiate pool allows for a service that can decide between two service types based on an intermediate return value. It differs from typical routing since it doesn’t depend on the request, but the response.

The original use case is support ALPN upgrades to HTTP/2, with a fallback to HTTP/1.

§Example

let mut pool = hyper_util::client::pool::negotiate::builder()
    .connect(some_tls_connector)
    .inspect(|c| c.negotiated_protocol() == b"h2")
    .fallback(http1_layer)
    .upgrade(http2_layer)
    .build();

// connect
let mut svc = pool.call(http::Uri::from_static("https://hyper.rs")).await?;
svc.ready().await;

// http1 or http2 is now set up
let resp = svc.call(some_http_req).await?;

Structs§

Builderdocsrs
A builder to configure a Negotiate.
Negotiatedocsrs
A negotiating pool over an inner make service.

Enums§

Negotiateddocsrs
A negotiated service returned by Negotiate.

Functions§

builder
Start a builder to construct a Negotiate pool.