diff options
author | Sam Scott <sam@osohq.com> | 2022-03-05 16:39:51 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-05 17:39:51 -0500 |
commit | 58c1832578a103498b0120469b7a5d84833ad1b5 (patch) | |
tree | 5af2062e91bc3fd92f93a08b64744a1c60e2ee6f | |
parent | d4c2caa53736ada8cd78e256fb95019b79e74bf7 (diff) |
Add an `actix` feature to provide a nicer error message (#57)
* Add an `actix` feature to provide a nicer error message
for people migrating from <= 0.8
* Fix tests.
* Bump version in readme.
-rw-r--r-- | .github/workflows/ci.yml | 20 | ||||
-rw-r--r-- | Cargo.toml | 4 | ||||
-rw-r--r-- | README.md | 2 | ||||
-rw-r--r-- | src/actix.rs | 5 | ||||
-rw-r--r-- | src/lib.rs | 13 | ||||
-rw-r--r-- | tests/test_actix.rs | 2 |
6 files changed, 36 insertions, 10 deletions
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0a1c937..2f399ca 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -54,12 +54,22 @@ jobs: profile: minimal toolchain: stable - name: Run test actix4 - run: cargo test --all-targets --features actix4 + run: | + cargo test --all-targets --features actix4 + cargo test --doc --features actix4 - name: Run test actix3 - run: cargo test --all-targets --features actix3 + run: | + cargo test --all-targets --features actix3 + cargo test --doc --features actix3 - name: Run test actix2 - run: cargo test --all-targets --features actix2 + run: | + cargo test --all-targets --features actix2 + cargo test --doc --features actix2 - name: Run test warp - run: cargo test --all-targets --features warp + run: | + cargo test --all-targets --features warp + cargo test --doc --features warp - name: Run test no feature - run: cargo test --all-targets + run: | + cargo test --all-targets + cargo test --doc @@ -9,7 +9,7 @@ license = "MIT/Apache-2.0" name = "serde_qs" repository = "https://github.com/samscott89/serde_qs" readme = "README.md" -version = "0.8.5" +version = "0.9.0" rust-version = "1.36" [dependencies] @@ -35,6 +35,8 @@ default = [] actix4 = ["actix-web4", "futures"] actix3 = ["actix-web3", "futures"] actix2 = ["actix-web2", "futures"] +# deprecated feature -- used to return a warning +actix = [] warp = ["futures", "tracing", "warp-framework"] [package.metadata.docs.rs] @@ -33,7 +33,7 @@ This crate works with Cargo and can be found on ```toml [dependencies] -serde_qs = "0.8" +serde_qs = "0.9" ``` Minimum supported Rust version is 1.36. diff --git a/src/actix.rs b/src/actix.rs index a522a68..a185212 100644 --- a/src/actix.rs +++ b/src/actix.rs @@ -60,7 +60,7 @@ impl ResponseError for QsError { /// /// // Use `QsQuery` extractor for query information. /// // The correct request for this handler would be `/users?id[]=1124&id[]=88"` -/// fn filter_users(info: QsQuery<UsersFilter>) -> HttpResponse { +/// async fn filter_users(info: QsQuery<UsersFilter>) -> HttpResponse { /// HttpResponse::Ok().body( /// info.id.iter().map(|i| i.to_string()).collect::<Vec<String>>().join(", ") /// ) @@ -164,7 +164,7 @@ where /// } /// /// /// deserialize `Info` from request's querystring -/// fn index(info: QsQuery<Info>) -> HttpResponse { +/// async fn index(info: QsQuery<Info>) -> HttpResponse { /// HttpResponse::Ok().body( /// format!("Welcome {}!", info.username) /// ) @@ -184,7 +184,6 @@ where /// ); /// } /// ``` - pub struct QsQueryConfig { ehandler: Option<Arc<dyn Fn(QsError, &HttpRequest) -> ActixError + Send + Sync>>, qs_config: QsConfig, @@ -174,6 +174,19 @@ extern crate serde; #[cfg(any(feature = "actix4", feature = "actix3", feature = "actix2"))] pub mod actix; + +#[cfg(feature = "actix")] +compile_error!( + r#"The `actix` feature was removed in v0.9 due to the proliferation of actix versions. +You must now specify the desired actix version by number. + +E.g. + +serde_qs = { version = "0.9", features = ["actix4"] } + +"# +); + mod de; mod error; mod ser; diff --git a/tests/test_actix.rs b/tests/test_actix.rs index 5159977..792afb2 100644 --- a/tests/test_actix.rs +++ b/tests/test_actix.rs @@ -1,5 +1,7 @@ #![cfg(any(feature = "actix4", feature = "actix3", feature = "actix2"))] +#[cfg(feature = "actix2")] +extern crate actix_web2 as actix_web; #[cfg(feature = "actix3")] extern crate actix_web3 as actix_web; #[cfg(feature = "actix4")] |