pub struct Hooks { /* private fields */ }Expand description
Lifecycle hooks for the HTTP client.
Implementations§
Source§impl Hooks
impl Hooks
Sourcepub fn on_request<F, Fut>(self, f: F) -> Selfwhere
F: Fn(RequestContext) -> Fut + Send + Sync + 'static,
Fut: Future<Output = Result<RequestContext>> + Send + 'static,
pub fn on_request<F, Fut>(self, f: F) -> Selfwhere
F: Fn(RequestContext) -> Fut + Send + Sync + 'static,
Fut: Future<Output = Result<RequestContext>> + Send + 'static,
Runs before the transport call. Return Err(Error::hook("…")) to cancel the request.
Sourcepub fn on_response<F, Fut>(self, f: F) -> Self
pub fn on_response<F, Fut>(self, f: F) -> Self
Runs after a buffered transport returns. Return Err(Error::hook("…")) to fail the request.
Sourcepub fn on_response_stream<F, Fut>(self, f: F) -> Selfwhere
F: Fn(StreamingResponseContext) -> Fut + Send + Sync + 'static,
Fut: Future<Output = Result<StreamingResponseMeta>> + Send + 'static,
pub fn on_response_stream<F, Fut>(self, f: F) -> Selfwhere
F: Fn(StreamingResponseContext) -> Fut + Send + Sync + 'static,
Fut: Future<Output = Result<StreamingResponseMeta>> + Send + 'static,
Runs after streaming transport returns, before the body is read.
Use this on RequestBuilder::send_stream instead of
on_response. Return updated StreamingResponseMeta (e.g. mutate headers).
Sourcepub fn on_success<F, Fut>(self, f: F) -> Self
pub fn on_success<F, Fut>(self, f: F) -> Self
Runs after a successful (2xx) buffered response; cannot abort the pipeline.
Sourcepub fn on_success_stream<F, Fut>(self, f: F) -> Self
pub fn on_success_stream<F, Fut>(self, f: F) -> Self
Runs after a successful (2xx) streaming response; cannot abort the pipeline.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Hooks
impl !RefUnwindSafe for Hooks
impl Send for Hooks
impl Sync for Hooks
impl Unpin for Hooks
impl UnsafeUnpin for Hooks
impl !UnwindSafe for Hooks
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more