Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use doc_auto_cfg instead of doc_cfg feature for docsrs #254

Merged
merged 1 commit into from Apr 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
57 changes: 2 additions & 55 deletions tower-http/src/builder.rs
Expand Up @@ -40,14 +40,15 @@ use tower_layer::Stack;
/// # service.ready().await.unwrap().call(Request::new(Body::empty())).await.unwrap();
/// # }
/// ```
#[cfg(feature = "util")]
// ^ work around rustdoc not inferring doc(cfg)s for cfg's from surrounding scopes
pub trait ServiceBuilderExt<L>: crate::sealed::Sealed<L> + Sized {
/// Propagate a header from the request to the response.
///
/// See [`tower_http::propagate_header`] for more details.
///
/// [`tower_http::propagate_header`]: crate::propagate_header
#[cfg(feature = "propagate-header")]
#[cfg_attr(docsrs, doc(cfg(feature = "propagate-header")))]
fn propagate_header(
self,
header: HeaderName,
Expand All @@ -60,7 +61,6 @@ pub trait ServiceBuilderExt<L>: crate::sealed::Sealed<L> + Sized {
/// [`tower_http::add_extension`]: crate::add_extension
/// [request extensions]: https://docs.rs/http/latest/http/struct.Extensions.html
#[cfg(feature = "add-extension")]
#[cfg_attr(docsrs, doc(cfg(feature = "add-extension")))]
fn add_extension<T>(
self,
value: T,
Expand All @@ -72,7 +72,6 @@ pub trait ServiceBuilderExt<L>: crate::sealed::Sealed<L> + Sized {
///
/// [`tower_http::map_request_body`]: crate::map_request_body
#[cfg(feature = "map-request-body")]
#[cfg_attr(docsrs, doc(cfg(feature = "map-request-body")))]
fn map_request_body<F>(
self,
f: F,
Expand All @@ -84,7 +83,6 @@ pub trait ServiceBuilderExt<L>: crate::sealed::Sealed<L> + Sized {
///
/// [`tower_http::map_response_body`]: crate::map_response_body
#[cfg(feature = "map-response-body")]
#[cfg_attr(docsrs, doc(cfg(feature = "map-response-body")))]
fn map_response_body<F>(
self,
f: F,
Expand All @@ -100,14 +98,6 @@ pub trait ServiceBuilderExt<L>: crate::sealed::Sealed<L> + Sized {
feature = "compression-deflate",
feature = "compression-gzip"
))]
#[cfg_attr(
docsrs,
doc(cfg(any(
feature = "compression-br",
feature = "compression-deflate",
feature = "compression-gzip"
)))
)]
fn compression(self) -> ServiceBuilder<Stack<crate::compression::CompressionLayer, L>>;

/// Decompress response bodies.
Expand All @@ -120,14 +110,6 @@ pub trait ServiceBuilderExt<L>: crate::sealed::Sealed<L> + Sized {
feature = "decompression-deflate",
feature = "decompression-gzip"
))]
#[cfg_attr(
docsrs,
doc(cfg(any(
feature = "decompression-br",
feature = "decompression-deflate",
feature = "decompression-gzip"
)))
)]
fn decompression(self) -> ServiceBuilder<Stack<crate::decompression::DecompressionLayer, L>>;

/// High level tracing that classifies responses using HTTP status codes.
Expand All @@ -140,7 +122,6 @@ pub trait ServiceBuilderExt<L>: crate::sealed::Sealed<L> + Sized {
/// [`tower_http::trace`]: crate::trace
/// [`TraceLayer`]: crate::trace::TraceLayer
#[cfg(feature = "trace")]
#[cfg_attr(docsrs, doc(cfg(feature = "trace")))]
fn trace_for_http(
self,
) -> ServiceBuilder<Stack<crate::trace::TraceLayer<SharedClassifier<ServerErrorsAsFailures>>, L>>;
Expand All @@ -155,7 +136,6 @@ pub trait ServiceBuilderExt<L>: crate::sealed::Sealed<L> + Sized {
/// [`tower_http::trace`]: crate::trace
/// [`TraceLayer`]: crate::trace::TraceLayer
#[cfg(feature = "trace")]
#[cfg_attr(docsrs, doc(cfg(feature = "trace")))]
fn trace_for_grpc(
self,
) -> ServiceBuilder<Stack<crate::trace::TraceLayer<SharedClassifier<GrpcErrorsAsFailures>>, L>>;
Expand All @@ -167,7 +147,6 @@ pub trait ServiceBuilderExt<L>: crate::sealed::Sealed<L> + Sized {
/// [`tower_http::follow_redirect`]: crate::follow_redirect
/// [`Standard`]: crate::follow_redirect::policy::Standard
#[cfg(feature = "follow-redirect")]
#[cfg_attr(docsrs, doc(cfg(feature = "follow-redirect")))]
fn follow_redirects(
self,
) -> ServiceBuilder<
Expand All @@ -184,7 +163,6 @@ pub trait ServiceBuilderExt<L>: crate::sealed::Sealed<L> + Sized {
/// [sensitive]: https://docs.rs/http/latest/http/header/struct.HeaderValue.html#method.set_sensitive
/// [`tower_http::sensitive_headers`]: crate::sensitive_headers
#[cfg(feature = "sensitive-headers")]
#[cfg_attr(docsrs, doc(cfg(feature = "sensitive-headers")))]
fn sensitive_headers<I>(
self,
headers: I,
Expand All @@ -199,7 +177,6 @@ pub trait ServiceBuilderExt<L>: crate::sealed::Sealed<L> + Sized {
/// [sensitive]: https://docs.rs/http/latest/http/header/struct.HeaderValue.html#method.set_sensitive
/// [`tower_http::sensitive_headers`]: crate::sensitive_headers
#[cfg(feature = "sensitive-headers")]
#[cfg_attr(docsrs, doc(cfg(feature = "sensitive-headers")))]
fn sensitive_request_headers(
self,
headers: std::sync::Arc<[HeaderName]>,
Expand All @@ -212,7 +189,6 @@ pub trait ServiceBuilderExt<L>: crate::sealed::Sealed<L> + Sized {
/// [sensitive]: https://docs.rs/http/latest/http/header/struct.HeaderValue.html#method.set_sensitive
/// [`tower_http::sensitive_headers`]: crate::sensitive_headers
#[cfg(feature = "sensitive-headers")]
#[cfg_attr(docsrs, doc(cfg(feature = "sensitive-headers")))]
fn sensitive_response_headers(
self,
headers: std::sync::Arc<[HeaderName]>,
Expand All @@ -227,7 +203,6 @@ pub trait ServiceBuilderExt<L>: crate::sealed::Sealed<L> + Sized {
///
/// [`tower_http::set_header`]: crate::set_header
#[cfg(feature = "set-header")]
#[cfg_attr(docsrs, doc(cfg(feature = "set-header")))]
fn override_request_header<M>(
self,
header_name: HeaderName,
Expand All @@ -242,7 +217,6 @@ pub trait ServiceBuilderExt<L>: crate::sealed::Sealed<L> + Sized {
///
/// [`tower_http::set_header`]: crate::set_header
#[cfg(feature = "set-header")]
#[cfg_attr(docsrs, doc(cfg(feature = "set-header")))]
fn append_request_header<M>(
self,
header_name: HeaderName,
Expand All @@ -255,7 +229,6 @@ pub trait ServiceBuilderExt<L>: crate::sealed::Sealed<L> + Sized {
///
/// [`tower_http::set_header`]: crate::set_header
#[cfg(feature = "set-header")]
#[cfg_attr(docsrs, doc(cfg(feature = "set-header")))]
fn insert_request_header_if_not_present<M>(
self,
header_name: HeaderName,
Expand All @@ -271,7 +244,6 @@ pub trait ServiceBuilderExt<L>: crate::sealed::Sealed<L> + Sized {
///
/// [`tower_http::set_header`]: crate::set_header
#[cfg(feature = "set-header")]
#[cfg_attr(docsrs, doc(cfg(feature = "set-header")))]
fn override_response_header<M>(
self,
header_name: HeaderName,
Expand All @@ -286,7 +258,6 @@ pub trait ServiceBuilderExt<L>: crate::sealed::Sealed<L> + Sized {
///
/// [`tower_http::set_header`]: crate::set_header
#[cfg(feature = "set-header")]
#[cfg_attr(docsrs, doc(cfg(feature = "set-header")))]
fn append_response_header<M>(
self,
header_name: HeaderName,
Expand All @@ -299,7 +270,6 @@ pub trait ServiceBuilderExt<L>: crate::sealed::Sealed<L> + Sized {
///
/// [`tower_http::set_header`]: crate::set_header
#[cfg(feature = "set-header")]
#[cfg_attr(docsrs, doc(cfg(feature = "set-header")))]
fn insert_response_header_if_not_present<M>(
self,
header_name: HeaderName,
Expand All @@ -312,7 +282,6 @@ pub trait ServiceBuilderExt<L>: crate::sealed::Sealed<L> + Sized {
///
/// [`tower_http::request_id`]: crate::request_id
#[cfg(feature = "request-id")]
#[cfg_attr(docsrs, doc(cfg(feature = "request-id")))]
fn set_request_id<M>(
self,
header_name: HeaderName,
Expand All @@ -327,7 +296,6 @@ pub trait ServiceBuilderExt<L>: crate::sealed::Sealed<L> + Sized {
///
/// [`tower_http::request_id`]: crate::request_id
#[cfg(feature = "request-id")]
#[cfg_attr(docsrs, doc(cfg(feature = "request-id")))]
fn set_x_request_id<M>(
self,
make_request_id: M,
Expand All @@ -347,7 +315,6 @@ pub trait ServiceBuilderExt<L>: crate::sealed::Sealed<L> + Sized {
///
/// [`tower_http::request_id`]: crate::request_id
#[cfg(feature = "request-id")]
#[cfg_attr(docsrs, doc(cfg(feature = "request-id")))]
fn propagate_request_id(
self,
header_name: HeaderName,
Expand All @@ -359,7 +326,6 @@ pub trait ServiceBuilderExt<L>: crate::sealed::Sealed<L> + Sized {
///
/// [`tower_http::request_id`]: crate::request_id
#[cfg(feature = "request-id")]
#[cfg_attr(docsrs, doc(cfg(feature = "request-id")))]
fn propagate_x_request_id(
self,
) -> ServiceBuilder<Stack<crate::request_id::PropagateRequestIdLayer, L>> {
Expand All @@ -372,7 +338,6 @@ pub trait ServiceBuilderExt<L>: crate::sealed::Sealed<L> + Sized {
///
/// [`tower_http::catch_panic`]: crate::catch_panic
#[cfg(feature = "catch-panic")]
#[cfg_attr(docsrs, doc(cfg(feature = "catch-panic")))]
fn catch_panic(
self,
) -> ServiceBuilder<
Expand Down Expand Up @@ -420,14 +385,6 @@ impl<L> ServiceBuilderExt<L> for ServiceBuilder<L> {
feature = "compression-deflate",
feature = "compression-gzip"
))]
#[cfg_attr(
docsrs,
doc(cfg(any(
feature = "compression-br",
feature = "compression-deflate",
feature = "compression-gzip"
)))
)]
fn compression(self) -> ServiceBuilder<Stack<crate::compression::CompressionLayer, L>> {
self.layer(crate::compression::CompressionLayer::new())
}
Expand All @@ -437,14 +394,6 @@ impl<L> ServiceBuilderExt<L> for ServiceBuilder<L> {
feature = "decompression-deflate",
feature = "decompression-gzip"
))]
#[cfg_attr(
docsrs,
doc(cfg(any(
feature = "decompression-br",
feature = "decompression-deflate",
feature = "decompression-gzip"
)))
)]
fn decompression(self) -> ServiceBuilder<Stack<crate::decompression::DecompressionLayer, L>> {
self.layer(crate::decompression::DecompressionLayer::new())
}
Expand All @@ -466,7 +415,6 @@ impl<L> ServiceBuilderExt<L> for ServiceBuilder<L> {
}

#[cfg(feature = "follow-redirect")]
#[cfg_attr(docsrs, doc(cfg(feature = "follow-redirect")))]
fn follow_redirects(
self,
) -> ServiceBuilder<
Expand Down Expand Up @@ -603,7 +551,6 @@ impl<L> ServiceBuilderExt<L> for ServiceBuilder<L> {
}

#[cfg(feature = "catch-panic")]
#[cfg_attr(docsrs, doc(cfg(feature = "catch-panic")))]
fn catch_panic(
self,
) -> ServiceBuilder<
Expand Down
3 changes: 0 additions & 3 deletions tower-http/src/compression/layer.rs
Expand Up @@ -38,23 +38,20 @@ impl CompressionLayer {

/// Sets whether to enable the gzip encoding.
#[cfg(feature = "compression-gzip")]
#[cfg_attr(docsrs, doc(cfg(feature = "compression-gzip")))]
pub fn gzip(mut self, enable: bool) -> Self {
self.accept.set_gzip(enable);
self
}

/// Sets whether to enable the Deflate encoding.
#[cfg(feature = "compression-deflate")]
#[cfg_attr(docsrs, doc(cfg(feature = "compression-deflate")))]
pub fn deflate(mut self, enable: bool) -> Self {
self.accept.set_deflate(enable);
self
}

/// Sets whether to enable the Brotli encoding.
#[cfg(feature = "compression-br")]
#[cfg_attr(docsrs, doc(cfg(feature = "compression-br")))]
pub fn br(mut self, enable: bool) -> Self {
self.accept.set_br(enable);
self
Expand Down
3 changes: 0 additions & 3 deletions tower-http/src/compression/service.rs
Expand Up @@ -42,23 +42,20 @@ impl<S, P> Compression<S, P> {

/// Sets whether to enable the gzip encoding.
#[cfg(feature = "compression-gzip")]
#[cfg_attr(docsrs, doc(cfg(feature = "compression-gzip")))]
pub fn gzip(mut self, enable: bool) -> Self {
self.accept.set_gzip(enable);
self
}

/// Sets whether to enable the Deflate encoding.
#[cfg(feature = "compression-deflate")]
#[cfg_attr(docsrs, doc(cfg(feature = "compression-deflate")))]
pub fn deflate(mut self, enable: bool) -> Self {
self.accept.set_deflate(enable);
self
}

/// Sets whether to enable the Brotli encoding.
#[cfg(feature = "compression-br")]
#[cfg_attr(docsrs, doc(cfg(feature = "compression-br")))]
pub fn br(mut self, enable: bool) -> Self {
self.accept.set_br(enable);
self
Expand Down
3 changes: 0 additions & 3 deletions tower-http/src/decompression/layer.rs
Expand Up @@ -32,23 +32,20 @@ impl DecompressionLayer {

/// Sets whether to request the gzip encoding.
#[cfg(feature = "decompression-gzip")]
#[cfg_attr(docsrs, doc(cfg(feature = "decompression-gzip")))]
pub fn gzip(mut self, enable: bool) -> Self {
self.accept.set_gzip(enable);
self
}

/// Sets whether to request the Deflate encoding.
#[cfg(feature = "decompression-deflate")]
#[cfg_attr(docsrs, doc(cfg(feature = "decompression-deflate")))]
pub fn deflate(mut self, enable: bool) -> Self {
self.accept.set_deflate(enable);
self
}

/// Sets whether to request the Brotli encoding.
#[cfg(feature = "decompression-br")]
#[cfg_attr(docsrs, doc(cfg(feature = "decompression-br")))]
pub fn br(mut self, enable: bool) -> Self {
self.accept.set_br(enable);
self
Expand Down
3 changes: 0 additions & 3 deletions tower-http/src/decompression/service.rs
Expand Up @@ -40,23 +40,20 @@ impl<S> Decompression<S> {

/// Sets whether to request the gzip encoding.
#[cfg(feature = "decompression-gzip")]
#[cfg_attr(docsrs, doc(cfg(feature = "decompression-gzip")))]
pub fn gzip(mut self, enable: bool) -> Self {
self.accept.set_gzip(enable);
self
}

/// Sets whether to request the Deflate encoding.
#[cfg(feature = "decompression-deflate")]
#[cfg_attr(docsrs, doc(cfg(feature = "decompression-deflate")))]
pub fn deflate(mut self, enable: bool) -> Self {
self.accept.set_deflate(enable);
self
}

/// Sets whether to request the Brotli encoding.
#[cfg(feature = "decompression-br")]
#[cfg_attr(docsrs, doc(cfg(feature = "decompression-br")))]
pub fn br(mut self, enable: bool) -> Self {
self.accept.set_br(enable);
self
Expand Down