tower_http_metrics/
util.rs

1#[cfg(feature = "tower")]
2use tower::ServiceBuilder;
3use tower_layer::Stack;
4
5#[cfg(feature = "server")]
6use crate::server::HttpServerMetricsLayer;
7
8#[cfg(feature = "tower")]
9pub trait HttpMetricsServiceBuilderExt<L> {
10    #[cfg(feature = "server")]
11    fn http_server_metrics(self) -> ServiceBuilder<Stack<HttpServerMetricsLayer, L>>;
12}
13
14#[cfg(feature = "tower")]
15impl<L> HttpMetricsServiceBuilderExt<L> for ServiceBuilder<L> {
16    #[cfg(feature = "server")]
17    fn http_server_metrics(self) -> ServiceBuilder<Stack<HttpServerMetricsLayer, L>> {
18        self.layer(HttpServerMetricsLayer::new())
19    }
20}