From 40ffdf0a627231758a70b30bd48bb6a10e1d1801 Mon Sep 17 00:00:00 2001 From: David Pedersen Date: Mon, 25 Apr 2022 15:47:53 +0200 Subject: [PATCH 1/4] Update to tower-http 0.3.0 --- axum-extra/Cargo.toml | 2 +- axum/CHANGELOG.md | 1 + axum/Cargo.toml | 4 ++-- examples/consume-body-in-extractor-or-middleware/Cargo.toml | 2 +- examples/cors/Cargo.toml | 2 +- examples/cors/src/main.rs | 4 ++-- examples/key-value-store/Cargo.toml | 2 +- examples/multipart-form/Cargo.toml | 2 +- examples/sse/Cargo.toml | 2 +- examples/static-file-server/Cargo.toml | 2 +- examples/testing/Cargo.toml | 2 +- examples/todos/Cargo.toml | 2 +- examples/tracing-aka-logging/Cargo.toml | 2 +- examples/websockets/Cargo.toml | 2 +- 14 files changed, 16 insertions(+), 15 deletions(-) diff --git a/axum-extra/Cargo.toml b/axum-extra/Cargo.toml index 4a33f6326d..6381c9946f 100644 --- a/axum-extra/Cargo.toml +++ b/axum-extra/Cargo.toml @@ -24,7 +24,7 @@ http = "0.2" mime = "0.3" pin-project-lite = "0.2" tower = { version = "0.4", default_features = false, features = ["util"] } -tower-http = { version = "0.2", features = ["map-response-body"] } +tower-http = { version = "0.3", features = ["map-response-body"] } tower-layer = "0.3" tower-service = "0.3" diff --git a/axum/CHANGELOG.md b/axum/CHANGELOG.md index 4326f9536c..d2cbd59369 100644 --- a/axum/CHANGELOG.md +++ b/axum/CHANGELOG.md @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - **added:** Add `response::ErrorResponse` and `response::Result` for `IntoResponse`-based error handling ([#921]) - **added:** Add `middleware::from_extractor` and deprecate `extract::extractor_middleware` ([#957]) +- **changed:** Update to tower-http 0.3 [#921]: https://github.com/tokio-rs/axum/pull/921 [#957]: https://github.com/tokio-rs/axum/pull/957 diff --git a/axum/Cargo.toml b/axum/Cargo.toml index 96a8d6153e..8fe8bb01e3 100644 --- a/axum/Cargo.toml +++ b/axum/Cargo.toml @@ -42,7 +42,7 @@ serde = "1.0" sync_wrapper = "0.1.1" tokio = { version = "1", features = ["time"] } tower = { version = "0.4.11", default-features = false, features = ["util", "buffer", "make"] } -tower-http = { version = "0.2.0", features = ["util", "map-response-body"] } +tower-http = { version = "0.3.0", features = ["util", "map-response-body"] } tower-layer = "0.3" tower-service = "0.3" @@ -81,7 +81,7 @@ features = [ ] [dev-dependencies.tower-http] -version = "0.2.0" +version = "0.3.0" features = ["full"] [package.metadata.docs.rs] diff --git a/examples/consume-body-in-extractor-or-middleware/Cargo.toml b/examples/consume-body-in-extractor-or-middleware/Cargo.toml index e501985f2e..a9694e1c94 100644 --- a/examples/consume-body-in-extractor-or-middleware/Cargo.toml +++ b/examples/consume-body-in-extractor-or-middleware/Cargo.toml @@ -9,6 +9,6 @@ axum = { path = "../../axum" } hyper = "0.14" tokio = { version = "1.0", features = ["full"] } tower = "0.4" -tower-http = { version = "0.2", features = ["map-request-body", "util"] } +tower-http = { version = "0.3", features = ["map-request-body", "util"] } tracing = "0.1" tracing-subscriber = { version = "0.3", features = ["env-filter"] } diff --git a/examples/cors/Cargo.toml b/examples/cors/Cargo.toml index 004ba7e4b1..44fbd5ca49 100644 --- a/examples/cors/Cargo.toml +++ b/examples/cors/Cargo.toml @@ -7,4 +7,4 @@ publish = false [dependencies] axum = { path = "../../axum" } tokio = { version = "1.0", features = ["full"] } -tower-http = { version = "0.2.0", features = ["cors"] } +tower-http = { version = "0.3.0", features = ["cors"] } diff --git a/examples/cors/src/main.rs b/examples/cors/src/main.rs index 28fa05f02f..3fc4a2e790 100644 --- a/examples/cors/src/main.rs +++ b/examples/cors/src/main.rs @@ -11,7 +11,7 @@ use axum::{ Json, Router, }; use std::net::SocketAddr; -use tower_http::cors::{CorsLayer, Origin}; +use tower_http::cors::{AllowOrigin, CorsLayer}; #[tokio::main] async fn main() { @@ -29,7 +29,7 @@ async fn main() { // it is required to add ".allow_headers(vec![http::header::CONTENT_TYPE])" // or see this issue https://github.com/tokio-rs/axum/issues/849 CorsLayer::new() - .allow_origin(Origin::exact("http://localhost:3000".parse().unwrap())) + .allow_origin(AllowOrigin::exact("http://localhost:3000".parse().unwrap())) .allow_methods(vec![Method::GET]), ); serve(app, 4000).await; diff --git a/examples/key-value-store/Cargo.toml b/examples/key-value-store/Cargo.toml index e18a64896b..b2ea5bf523 100644 --- a/examples/key-value-store/Cargo.toml +++ b/examples/key-value-store/Cargo.toml @@ -10,4 +10,4 @@ tokio = { version = "1.0", features = ["full"] } tracing = "0.1" tracing-subscriber = { version = "0.3", features = ["env-filter"] } tower = { version = "0.4", features = ["util", "timeout", "load-shed", "limit"] } -tower-http = { version = "0.2.0", features = ["add-extension", "auth", "compression-full", "trace"] } +tower-http = { version = "0.3.0", features = ["add-extension", "auth", "compression-full", "trace"] } diff --git a/examples/multipart-form/Cargo.toml b/examples/multipart-form/Cargo.toml index c270f7ec3b..cf7d77b125 100644 --- a/examples/multipart-form/Cargo.toml +++ b/examples/multipart-form/Cargo.toml @@ -9,4 +9,4 @@ axum = { path = "../../axum", features = ["multipart"] } tokio = { version = "1.0", features = ["full"] } tracing = "0.1" tracing-subscriber = { version = "0.3", features = ["env-filter"] } -tower-http = { version = "0.2.0", features = ["trace"] } +tower-http = { version = "0.3.0", features = ["trace"] } diff --git a/examples/sse/Cargo.toml b/examples/sse/Cargo.toml index e9df22a5a5..f119d63afb 100644 --- a/examples/sse/Cargo.toml +++ b/examples/sse/Cargo.toml @@ -9,7 +9,7 @@ axum = { path = "../../axum", features = ["headers"] } tokio = { version = "1.0", features = ["full"] } tracing = "0.1" tracing-subscriber = { version = "0.3", features = ["env-filter"] } -tower-http = { version = "0.2.0", features = ["fs", "trace"] } +tower-http = { version = "0.3.0", features = ["fs", "trace"] } futures = "0.3" tokio-stream = "0.1" headers = "0.3" diff --git a/examples/static-file-server/Cargo.toml b/examples/static-file-server/Cargo.toml index af39d55056..d927ec971b 100644 --- a/examples/static-file-server/Cargo.toml +++ b/examples/static-file-server/Cargo.toml @@ -9,4 +9,4 @@ axum = { path = "../../axum" } tokio = { version = "1.0", features = ["full"] } tracing = "0.1" tracing-subscriber = { version = "0.3", features = ["env-filter"] } -tower-http = { version = "0.2.0", features = ["fs", "trace"] } +tower-http = { version = "0.3.0", features = ["fs", "trace"] } diff --git a/examples/testing/Cargo.toml b/examples/testing/Cargo.toml index 30ff33c44a..e70223b501 100644 --- a/examples/testing/Cargo.toml +++ b/examples/testing/Cargo.toml @@ -10,7 +10,7 @@ mime = "0.3" tokio = { version = "1.0", features = ["full"] } tracing = "0.1" tracing-subscriber = { version = "0.3", features = ["env-filter"] } -tower-http = { version = "0.2.0", features = ["trace"] } +tower-http = { version = "0.3.0", features = ["trace"] } serde_json = "1.0" hyper = { version = "0.14", features = ["full"] } diff --git a/examples/todos/Cargo.toml b/examples/todos/Cargo.toml index 896d2f7ae6..debc10a9ba 100644 --- a/examples/todos/Cargo.toml +++ b/examples/todos/Cargo.toml @@ -10,6 +10,6 @@ tokio = { version = "1.0", features = ["full"] } tracing = "0.1" tracing-subscriber = { version = "0.3", features = ["env-filter"] } tower = { version = "0.4", features = ["util", "timeout"] } -tower-http = { version = "0.2.0", features = ["add-extension", "trace"] } +tower-http = { version = "0.3.0", features = ["add-extension", "trace"] } uuid = { version = "0.8", features = ["serde", "v4"] } serde = { version = "1.0", features = ["derive"] } diff --git a/examples/tracing-aka-logging/Cargo.toml b/examples/tracing-aka-logging/Cargo.toml index 4def1c168c..a64f798b98 100644 --- a/examples/tracing-aka-logging/Cargo.toml +++ b/examples/tracing-aka-logging/Cargo.toml @@ -9,4 +9,4 @@ axum = { path = "../../axum" } tokio = { version = "1.0", features = ["full"] } tracing = "0.1" tracing-subscriber = { version = "0.3", features = ["env-filter"] } -tower-http = { version = "0.2.0", features = ["trace"] } +tower-http = { version = "0.3.0", features = ["trace"] } diff --git a/examples/websockets/Cargo.toml b/examples/websockets/Cargo.toml index 7d2ae9fe1c..67935f3c9a 100644 --- a/examples/websockets/Cargo.toml +++ b/examples/websockets/Cargo.toml @@ -9,5 +9,5 @@ axum = { path = "../../axum", features = ["ws", "headers"] } tokio = { version = "1.0", features = ["full"] } tracing = "0.1" tracing-subscriber = { version = "0.3", features = ["env-filter"] } -tower-http = { version = "0.2.0", features = ["fs", "trace"] } +tower-http = { version = "0.3.0", features = ["fs", "trace"] } headers = "0.3" From 5a037b5a8e5830a9c63fa15a321f857f25860378 Mon Sep 17 00:00:00 2001 From: David Pedersen Date: Mon, 25 Apr 2022 15:48:31 +0200 Subject: [PATCH 2/4] changelog link --- axum/CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/axum/CHANGELOG.md b/axum/CHANGELOG.md index d2cbd59369..46122495a1 100644 --- a/axum/CHANGELOG.md +++ b/axum/CHANGELOG.md @@ -10,10 +10,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - **added:** Add `response::ErrorResponse` and `response::Result` for `IntoResponse`-based error handling ([#921]) - **added:** Add `middleware::from_extractor` and deprecate `extract::extractor_middleware` ([#957]) -- **changed:** Update to tower-http 0.3 +- **changed:** Update to tower-http 0.3 ([#965]) [#921]: https://github.com/tokio-rs/axum/pull/921 [#957]: https://github.com/tokio-rs/axum/pull/957 +[#965]: https://github.com/tokio-rs/axum/pull/965 # 0.5.3 (19. April, 2022) From 92088824fc89686a8ff61b4d05917f8eff3f6e9e Mon Sep 17 00:00:00 2001 From: David Pedersen Date: Mon, 25 Apr 2022 16:25:13 +0200 Subject: [PATCH 3/4] Update examples/cors/src/main.rs Co-authored-by: Jonas Platte --- examples/cors/src/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/cors/src/main.rs b/examples/cors/src/main.rs index 3fc4a2e790..61570aef8d 100644 --- a/examples/cors/src/main.rs +++ b/examples/cors/src/main.rs @@ -29,7 +29,7 @@ async fn main() { // it is required to add ".allow_headers(vec![http::header::CONTENT_TYPE])" // or see this issue https://github.com/tokio-rs/axum/issues/849 CorsLayer::new() - .allow_origin(AllowOrigin::exact("http://localhost:3000".parse().unwrap())) + .allow_origin("http://localhost:3000".parse::().unwrap()) .allow_methods(vec![Method::GET]), ); serve(app, 4000).await; From 1d78aff9561c30a5112698ef60c0d0df4a2ed195 Mon Sep 17 00:00:00 2001 From: David Pedersen Date: Mon, 25 Apr 2022 16:54:03 +0200 Subject: [PATCH 4/4] fixup --- examples/cors/src/main.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/cors/src/main.rs b/examples/cors/src/main.rs index 61570aef8d..939b49d448 100644 --- a/examples/cors/src/main.rs +++ b/examples/cors/src/main.rs @@ -5,13 +5,13 @@ //! ``` use axum::{ - http::Method, + http::{HeaderValue, Method}, response::{Html, IntoResponse}, routing::get, Json, Router, }; use std::net::SocketAddr; -use tower_http::cors::{AllowOrigin, CorsLayer}; +use tower_http::cors::CorsLayer; #[tokio::main] async fn main() {