diff --git a/Cargo.toml b/Cargo.toml index 0950289..000e5d2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,6 +6,5 @@ members = [ "hitbox-redis", "hitbox-stretto", "hitbox-tower", - "hitbox-qs", "examples", ] diff --git a/hitbox-http/Cargo.toml b/hitbox-http/Cargo.toml index 62b4993..0f5c67f 100644 --- a/hitbox-http/Cargo.toml +++ b/hitbox-http/Cargo.toml @@ -19,13 +19,13 @@ http = "0.2" http-body = "0.4" hitbox = { path = "../hitbox", version = "0.1" } hitbox-backend = { path = "../hitbox-backend", version = "0.1" } -hitbox-qs = { path = "../hitbox-qs", version = "0.1" } -serde = "1.0.144" bytes = "1" chrono = "0.4" hyper = { version = "0.14", features = ["stream"] } futures = { version = "0.3", default-features = false } actix-router = "0.5" +serde_qs = "0.12" +serde = { version = "1", features = ["derive"] } [dev-dependencies] tokio = { version = "1", features = ["test-util"], default-features = false } diff --git a/hitbox-http/src/extractors/query.rs b/hitbox-http/src/extractors/query.rs index ce745a0..2d2ae0f 100644 --- a/hitbox-http/src/extractors/query.rs +++ b/hitbox-http/src/extractors/query.rs @@ -34,16 +34,17 @@ where .parts() .uri .query() - .map(hitbox_qs::parse) - .map(|m| m.get(&self.name).map(hitbox_qs::Value::inner)) + .map(crate::query::parse) + .map(|m| m.get(&self.name).map(crate::query::Value::inner)) .flatten() .unwrap_or_default(); let mut parts = self.inner.get(subject).await; for value in values { - parts.push(KeyPart { - key: self.name.clone(), - value: Some(value), - });} + parts.push(KeyPart { + key: self.name.clone(), + value: Some(value), + }); + } parts } } diff --git a/hitbox-http/src/lib.rs b/hitbox-http/src/lib.rs index a4b0509..3403d5c 100644 --- a/hitbox-http/src/lib.rs +++ b/hitbox-http/src/lib.rs @@ -1,6 +1,7 @@ mod body; pub mod extractors; pub mod predicates; +mod query; mod request; mod response; diff --git a/hitbox-http/src/predicates/query.rs b/hitbox-http/src/predicates/query.rs index 15043a2..73b91e4 100644 --- a/hitbox-http/src/predicates/query.rs +++ b/hitbox-http/src/predicates/query.rs @@ -1,11 +1,10 @@ use crate::CacheableHttpRequest; use async_trait::async_trait; use hitbox::predicates::{Operation, Predicate, PredicateResult}; -use hitbox_qs::Value; pub struct Query
{ pub name: String, - pub value: Value, + pub value: crate::query::Value, pub operation: Operation, inner: P, } @@ -21,7 +20,7 @@ where fn query(self, name: String, value: String) -> Query
{ Query { name, - value: Value::Scalar(value), + value: crate::query::Value::Scalar(value), operation: Operation::Eq, inner: self, } @@ -40,11 +39,11 @@ where match self.inner.check(request).await { PredicateResult::Cacheable(request) => { let op = match self.operation { - Operation::Eq => Value::eq, + Operation::Eq => crate::query::Value::eq, Operation::In => unimplemented!(), }; match request.parts().uri.query() { - Some(query_string) => match hitbox_qs::parse(query_string).get(&self.name) { + Some(query_string) => match crate::query::parse(query_string).get(&self.name) { Some(value) if op(value, &self.value) => { PredicateResult::Cacheable(request) } diff --git a/hitbox-qs/src/lib.rs b/hitbox-http/src/query.rs similarity index 100% rename from hitbox-qs/src/lib.rs rename to hitbox-http/src/query.rs index 7e957b6..857700e 100644 --- a/hitbox-qs/src/lib.rs +++ b/hitbox-http/src/query.rs @@ -1,5 +1,5 @@ -use std::collections::HashMap; use serde::Deserialize; +use std::collections::HashMap; #[derive(Debug, Deserialize, PartialEq, Eq)] #[serde(untagged)] diff --git a/hitbox-http/tests/extractors/mod.rs b/hitbox-http/tests/extractors/mod.rs index 1885e27..763857c 100644 --- a/hitbox-http/tests/extractors/mod.rs +++ b/hitbox-http/tests/extractors/mod.rs @@ -1,5 +1,5 @@ mod header; -mod query; mod method; mod multiple; mod path; +mod query; diff --git a/hitbox-qs/Cargo.toml b/hitbox-qs/Cargo.toml deleted file mode 100644 index 2459940..0000000 --- a/hitbox-qs/Cargo.toml +++ /dev/null @@ -1,10 +0,0 @@ -[package] -name = "hitbox-qs" -version = "0.1.0" -edition = "2021" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] -serde_qs = "0.12" -serde = { version = "1", features = ["derive"] }