pub trait ClientExt<B>: Client<B>{
// Provided methods
fn get(
&self,
url: &Url,
headers: impl IntoIterator<Item = (HeaderName, HeaderValue)>,
) -> impl Future<Output = Result<Response<Incoming>, Error>>
where B: Default { ... }
fn post(
&self,
url: &Url,
headers: impl IntoIterator<Item = (HeaderName, HeaderValue)>,
body: B,
) -> impl Future<Output = Result<Response<Incoming>, Error>> { ... }
fn get_with_body(
&self,
url: &Url,
headers: impl IntoIterator<Item = (HeaderName, HeaderValue)>,
body: B,
) -> impl Future<Output = Result<Response<Incoming>, Error>> { ... }
}Expand description
Extension trait adding specific HTTP method functions (GET, POST, etc.) on top of the base
Client trait.
Provided Methods§
Sourcefn get(
&self,
url: &Url,
headers: impl IntoIterator<Item = (HeaderName, HeaderValue)>,
) -> impl Future<Output = Result<Response<Incoming>, Error>>where
B: Default,
fn get(
&self,
url: &Url,
headers: impl IntoIterator<Item = (HeaderName, HeaderValue)>,
) -> impl Future<Output = Result<Response<Incoming>, Error>>where
B: Default,
Sends an HTTP GET request to the connected server and returns the Response.
By definition, HTTP GET requests do not contain a body. Note that the Response body of
Incoming means the body must be collected separately from the Response status and
headers; this allows the status/headers to be checked before the full body has arrived.
Sourcefn post(
&self,
url: &Url,
headers: impl IntoIterator<Item = (HeaderName, HeaderValue)>,
body: B,
) -> impl Future<Output = Result<Response<Incoming>, Error>>
fn post( &self, url: &Url, headers: impl IntoIterator<Item = (HeaderName, HeaderValue)>, body: B, ) -> impl Future<Output = Result<Response<Incoming>, Error>>
Sourcefn get_with_body(
&self,
url: &Url,
headers: impl IntoIterator<Item = (HeaderName, HeaderValue)>,
body: B,
) -> impl Future<Output = Result<Response<Incoming>, Error>>
fn get_with_body( &self, url: &Url, headers: impl IntoIterator<Item = (HeaderName, HeaderValue)>, body: B, ) -> impl Future<Output = Result<Response<Incoming>, Error>>
Sends an HTTP GET request carrying a body and returns the Response.
A GET with a request body is unusual, but it is exactly what the upstream Tailnet-Lock sync
RPCs (/machine/tka/sync/{offer,send}) do: control routes on the path and reads a JSON body
off a GET. This mirrors ClientExt::post but with the GET method, so callers that must
match that wire shape don’t have to hand-build a Request (and reach for the private
origin-form target helper). Same header defaults as get/post (UA + Host).
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".