diff --git a/axum-core/Cargo.toml b/axum-core/Cargo.toml index 6ead90a7..4c4904c7 100644 --- a/axum-core/Cargo.toml +++ b/axum-core/Cargo.toml @@ -11,6 +11,9 @@ readme = "README.md" repository = "https://github.com/tokio-rs/axum" version = "0.3.3" # remember to also bump the version that axum depends on +[features] +__private_docs = ["dep:tower-http"] + [dependencies] async-trait = "0.1" bytes = "1.0" @@ -21,6 +24,9 @@ mime = "0.3.16" tower-layer = "0.3" tower-service = "0.3" +# optional dependencies +tower-http = { version = "0.4", optional = true, features = ["limit"] } + [build-dependencies] rustversion = "1.0.9" diff --git a/axum-core/src/extract/default_body_limit.rs b/axum-core/src/extract/default_body_limit.rs index 26891548..7b37f1ed 100644 --- a/axum-core/src/extract/default_body_limit.rs +++ b/axum-core/src/extract/default_body_limit.rs @@ -69,7 +69,7 @@ use tower_layer::Layer; /// [`Json`]: https://docs.rs/axum/0.6.0/axum/struct.Json.html /// [`Form`]: https://docs.rs/axum/0.6.0/axum/struct.Form.html /// [`FromRequest`]: crate::extract::FromRequest -/// [`RequestBodyLimit`]: https://docs.rs/tower-http/latest/tower_http/limit/struct.RequestBodyLimit.html +/// [`RequestBodyLimit`]: tower_http::limit::RequestBodyLimit /// [`RequestExt::with_limited_body`]: crate::RequestExt::with_limited_body /// [`RequestExt::into_limited_body`]: crate::RequestExt::into_limited_body #[derive(Debug, Clone)] @@ -113,7 +113,6 @@ impl DefaultBodyLimit { /// .layer(RequestBodyLimitLayer::new(10 * 1000 * 1000)); /// ``` /// - /// [`tower_http::limit`]: https://docs.rs/tower-http/0.3.4/tower_http/limit/index.html /// [`Bytes`]: bytes::Bytes /// [`Json`]: https://docs.rs/axum/0.6.0/axum/struct.Json.html /// [`Form`]: https://docs.rs/axum/0.6.0/axum/struct.Form.html diff --git a/axum-core/src/extract/rejection.rs b/axum-core/src/extract/rejection.rs index 8afe112a..09d70191 100644 --- a/axum-core/src/extract/rejection.rs +++ b/axum-core/src/extract/rejection.rs @@ -30,8 +30,6 @@ define_rejection! { /// /// This can _only_ happen when you're using [`tower_http::limit::RequestBodyLimitLayer`] or /// otherwise wrapping request bodies in [`http_body::Limited`]. - /// - /// [`tower_http::limit::RequestBodyLimitLayer`]: https://docs.rs/tower-http/0.3/tower_http/limit/struct.RequestBodyLimitLayer.html pub struct LengthLimitError(Error); } diff --git a/axum/Cargo.toml b/axum/Cargo.toml index fef5a5ec..bf05310e 100644 --- a/axum/Cargo.toml +++ b/axum/Cargo.toml @@ -27,38 +27,7 @@ tower-log = ["tower/log"] ws = ["tokio", "dep:tokio-tungstenite", "dep:sha1", "dep:base64"] # Required for intra-doc links to resolve correctly -__private_docs = [ - "tower/full", - # all tower-http features except (de)?compression-zstd which doesn't - # build on `--target armv5te-unknown-linux-musleabi` - "tower-http/add-extension", - "tower-http/auth", - "tower-http/catch-panic", - "tower-http/compression-br", - "tower-http/compression-deflate", - "tower-http/compression-gzip", - "tower-http/cors", - "tower-http/decompression-br", - "tower-http/decompression-deflate", - "tower-http/decompression-gzip", - "tower-http/follow-redirect", - "tower-http/fs", - "tower-http/limit", - "tower-http/map-request-body", - "tower-http/map-response-body", - "tower-http/metrics", - "tower-http/normalize-path", - "tower-http/propagate-header", - "tower-http/redirect", - "tower-http/request-id", - "tower-http/sensitive-headers", - "tower-http/set-header", - "tower-http/set-status", - "tower-http/timeout", - "tower-http/trace", - "tower-http/util", - "tower-http/validate-request", -] +__private_docs = ["tower/full", "dep:tower-http"] [dependencies] async-trait = "0.1.43" @@ -92,7 +61,41 @@ serde_urlencoded = { version = "0.7", optional = true } sha1 = { version = "0.10", optional = true } tokio = { package = "tokio", version = "1.25.0", features = ["time"], optional = true } tokio-tungstenite = { version = "0.18.0", optional = true } -tower-http = { version = "0.4", features = ["util", "map-response-body"], optional = true } + +[dependencies.tower-http] +version = "0.4" +optional = true +features = [ + # all tower-http features except (de)?compression-zstd which doesn't + # build on `--target armv5te-unknown-linux-musleabi` + "add-extension", + "auth", + "catch-panic", + "compression-br", + "compression-deflate", + "compression-gzip", + "cors", + "decompression-br", + "decompression-deflate", + "decompression-gzip", + "follow-redirect", + "fs", + "limit", + "map-request-body", + "map-response-body", + "metrics", + "normalize-path", + "propagate-header", + "redirect", + "request-id", + "sensitive-headers", + "set-header", + "set-status", + "timeout", + "trace", + "util", + "validate-request", +] [build-dependencies] rustversion = "1.0.9"