Skip to main content

tower_reqwest/
lib.rs

1#![cfg_attr(docsrs, feature(doc_cfg))]
2
3//! # Overview
4//!
5#![doc = include_utils::include_md!("README.md:description")]
6
7use tower_layer::Layer;
8
9mod adapters;
10#[cfg(feature = "auth")]
11pub mod auth;
12#[cfg(feature = "set-header")]
13pub mod set_header;
14
15/// Adapter type to creating Tower HTTP services from the various clients.
16#[derive(Debug, Clone)]
17pub struct HttpClientService<S>(S);
18
19impl<S> HttpClientService<S> {
20    /// Creates a new HTTP client service wrapper.
21    pub const fn new(inner: S) -> Self {
22        Self(inner)
23    }
24}
25
26/// Layer that creates [`HttpClientService`] from the inner service.
27///
28/// # Examples
29///
30#[doc = include_utils::include_md!("README.md:description")]
31///
32#[derive(Debug, Clone, Copy)]
33pub struct HttpClientLayer;
34
35impl<S> Layer<S> for HttpClientLayer {
36    type Service = HttpClientService<S>;
37
38    fn layer(&self, service: S) -> Self::Service {
39        HttpClientService(service)
40    }
41}