HttpService

Trait HttpService 

Source
pub trait HttpService:
    Send
    + Sync
    + Debug {
    // Required method
    fn call<'a, 'async_trait>(
        &'a self,
        req: &'a (dyn Fn() -> Result<Request<Bytes>, AgentError> + Send + Sync),
        max_retries: usize,
        size_limit: Option<usize>,
    ) -> Pin<Box<dyn Future<Output = Result<Response<Bytes>, AgentError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'a: 'async_trait;
}
Expand description

HTTP client middleware. Implemented automatically for reqwest-compatible by-ref tower::Service, such as reqwest_middleware.

Required Methods§

Source

fn call<'a, 'async_trait>( &'a self, req: &'a (dyn Fn() -> Result<Request<Bytes>, AgentError> + Send + Sync), max_retries: usize, size_limit: Option<usize>, ) -> Pin<Box<dyn Future<Output = Result<Response<Bytes>, AgentError>> + Send + 'async_trait>>
where Self: 'async_trait, 'a: 'async_trait,

Perform a HTTP request. Any retry logic should call req again to get a new request.

Implementors§

Source§

impl<T> HttpService for T
where for<'a> &'a T: Service<Request, Response = Response, Error = Error>, for<'a> <&'a Self as Service<Request>>::Future: Send, T: Send + Sync + Debug + ?Sized,