tower-conneg 1.1.0

Tower middleware for HTTP content negotiation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
//! Hyper client integration.

use tower::Layer;

use crate::client::{ClientNegotiateLayer, ClientNegotiateService};
use crate::core::ClientConfig;

/// Extension trait for wrapping Tower services with content negotiation.
pub trait HyperClientExt: Sized {
    /// Wraps the service with content negotiation middleware.
    fn with_content_negotiation(self, config: ClientConfig) -> ClientNegotiateService<Self>;
}

impl<S> HyperClientExt for S {
    fn with_content_negotiation(self, config: ClientConfig) -> ClientNegotiateService<Self> {
        ClientNegotiateLayer::new(config).layer(self)
    }
}