pub struct HttpEngine<A> { /* private fields */ }Expand description
An HTTP transport for one tapes deployment, with the credential half left
to an HttpAuth.
http is None only if the no-redirect client could not be built at all —
in which case every request errors, rather than any fallback silently
following redirects.
Implementations§
Source§impl HttpEngine<NoAuth>
impl HttpEngine<NoAuth>
Source§impl<A> HttpEngine<A>
impl<A> HttpEngine<A>
Sourcepub fn with_auth(base: Url, auth: A) -> Self
pub fn with_auth(base: Url, auth: A) -> Self
Build a transport against base, authorised by auth.
The join mode is PathMode::Direct; a deployment that mounts tapes
under a gateway prefix adds HttpEngine::under_base.
Sourcepub fn under_base(self) -> Self
pub fn under_base(self) -> Self
Join contract paths under the base’s own prefix rather than at its root.
What a deployment that mounts tapes behind a gateway needs: a
root-absolute join would send /v1/sessions to the edge root — a 404 at
best, a wrong-gateway route at worst, and neither looks like a URL bug
at the call site. The base must end in a slash.
Sourcepub fn with_client(self, http: Client) -> Self
pub fn with_client(self, http: Client) -> Self
Send on the caller’s own client rather than the engine’s.
The injection point for a TLS policy, a proxy configuration, or a connection pool a consumer already holds. The per-response origin check still applies, so an injected client that follows redirects cannot walk a request onto another host unnoticed.
Source§impl<A: HttpAuth> HttpEngine<A>
impl<A: HttpAuth> HttpEngine<A>
Sourcepub async fn fetch_discovery(&self) -> Result<Value>
pub async fn fetch_discovery(&self) -> Result<Value>
GET /v1/cassettes — the cassette discovery document, raw.
§Errors
Any transport, status, or decode failure; see crate::Error.
Sourcepub async fn fetch_spec(
&self,
path: &str,
etag: Option<&str>,
) -> Result<SpecFetch>
pub async fn fetch_spec( &self, path: &str, etag: Option<&str>, ) -> Result<SpecFetch>
GET /v1/cassettes/{name}/openapi.json — one cassette’s own document.
path is the openapi_path discovery published rather than a path this
client builds, so the server stays free to move the route; it is
therefore untrusted, and refused unless it is plainly server-relative.
§Errors
Any transport, status, or decode failure; see crate::Error.
Sourcepub async fn execute(&self, call: &Call<'_>) -> Result<Value>
pub async fn execute(&self, call: &Call<'_>) -> Result<Value>
Make one call described by an OpenAPI document and decode the JSON.
§Errors
Any transport, status, or decode failure; see crate::Error.
Sourcepub async fn execute_stream(&self, call: &Call<'_>) -> Result<Response>
pub async fn execute_stream(&self, call: &Call<'_>) -> Result<Response>
Make one described call and hand back the live response for streaming.
A non-success status is read and surfaced as Error::ApiStatus here,
so a caller streaming to a file can never write an error page into it.
§Errors
Error::ApiStatus for any non-success answer, or the transport’s own
failure.
Trait Implementations§
Source§impl<A: Clone> Clone for HttpEngine<A>
impl<A: Clone> Clone for HttpEngine<A>
Source§fn clone(&self) -> HttpEngine<A>
fn clone(&self) -> HttpEngine<A>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more