Skip to content

Commit 0478f4a

Browse files
authored
Merge pull request #502 from AmbireTech/replace_serde_urlencoded
Replaced serde_urlencoded library with serde_qs
2 parents a6bc1d8 + 15e7416 commit 0478f4a

File tree

8 files changed

+17
-19
lines changed

8 files changed

+17
-19
lines changed

Cargo.lock

Lines changed: 2 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

primitives/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ once_cell = "^1.8"
7272
[dev-dependencies]
7373
pretty_assertions = "1"
7474
tokio = { version = "1", features = ["rt-multi-thread", "macros"] }
75-
serde_urlencoded = "^0.7"
75+
serde_qs = "0.9.2"
7676

7777
[package.metadata.docs.rs]
7878
all-features = true

primitives/src/sentry.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -719,7 +719,7 @@ pub mod campaign_list {
719719
*CREATOR, *LEADER
720720
);
721721
let query_leader_encoded =
722-
serde_urlencoded::from_str::<CampaignListQuery>(&query_leader_string)
722+
serde_qs::from_str::<CampaignListQuery>(&query_leader_string)
723723
.expect("should encode");
724724

725725
pretty_assertions::assert_eq!(query_leader_encoded, query_leader);
@@ -735,7 +735,7 @@ pub mod campaign_list {
735735
*CREATOR, *FOLLOWER
736736
);
737737
let query_validator_encoded =
738-
serde_urlencoded::from_str::<CampaignListQuery>(&query_validator_string)
738+
serde_qs::from_str::<CampaignListQuery>(&query_validator_string)
739739
.expect("should encode");
740740

741741
pretty_assertions::assert_eq!(query_validator_encoded, query_validator,);
@@ -750,7 +750,7 @@ pub mod campaign_list {
750750
let query_no_validator_string =
751751
format!("page=0&activeTo=1612162800&creator={}", *CREATOR);
752752
let query_no_validator_encoded =
753-
serde_urlencoded::from_str::<CampaignListQuery>(&query_no_validator_string)
753+
serde_qs::from_str::<CampaignListQuery>(&query_no_validator_string)
754754
.expect("should encode");
755755

756756
pretty_assertions::assert_eq!(query_no_validator_encoded, query_no_validator,);

sentry/Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,14 @@ envy = "0.4"
5353
# Serde
5454
serde = { version = "^1.0", features = ["derive"] }
5555
serde_json = "^1.0"
56-
serde_urlencoded = "^0.7"
56+
serde_qs = "0.9.2"
5757
# Other
5858
thiserror = "^1.0"
5959
once_cell = "1.5.2"
6060
# UA parsing for `/units-for-slot` route
6161
woothee = "0.13"
6262
# Making requests to the platform
6363
reqwest = { version = "0.11", features = ["json", "cookies"] }
64-
serde_qs = "0.9.2"
6564

6665
[dev-dependencies]
6766
pretty_assertions = "1"

sentry/src/routes/campaign.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ pub async fn campaign_list<C: Locked + 'static>(
283283
req: Request<Body>,
284284
app: &Application<C>,
285285
) -> Result<Response<Body>, ResponseError> {
286-
let query = serde_urlencoded::from_str::<CampaignListQuery>(req.uri().query().unwrap_or(""))?;
286+
let query = serde_qs::from_str::<CampaignListQuery>(req.uri().query().unwrap_or(""))?;
287287

288288
let limit = app.config.campaigns_find_limit;
289289
let skip = query
@@ -1552,7 +1552,7 @@ mod test {
15521552
.expect("Should insert dummy campaign");
15531553

15541554
let build_request = |query: CampaignListQuery| {
1555-
let query = serde_urlencoded::to_string(query).expect("should parse query");
1555+
let query = serde_qs::to_string(&query).expect("should parse query");
15561556
Request::builder()
15571557
.uri(format!("http://127.0.0.1/v5/campaign/list?{}", query))
15581558
.body(Body::empty())

sentry/src/routes/channel.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ pub async fn channel_list<C: Locked + 'static>(
4040
req: Request<Body>,
4141
app: &Application<C>,
4242
) -> Result<Response<Body>, ResponseError> {
43-
let query = serde_urlencoded::from_str::<ChannelListQuery>(req.uri().query().unwrap_or(""))?;
43+
let query = serde_qs::from_str::<ChannelListQuery>(req.uri().query().unwrap_or(""))?;
4444
let skip = query
4545
.page
4646
.checked_mul(app.config.channels_find_limit.into())
@@ -96,7 +96,7 @@ pub async fn last_approved<C: Locked + 'static>(
9696
return Ok(default_response);
9797
}
9898

99-
let query = serde_urlencoded::from_str::<LastApprovedQuery>(req.uri().query().unwrap_or(""))?;
99+
let query = serde_qs::from_str::<LastApprovedQuery>(req.uri().query().unwrap_or(""))?;
100100
let validators = vec![channel.leader, channel.follower];
101101
let channel_id = channel.id();
102102
let heartbeats = if query.with_heartbeat.is_some() {
@@ -247,7 +247,7 @@ pub async fn get_all_spender_limits<C: Locked + 'static>(
247247
.expect("Request should have Channel")
248248
.context;
249249

250-
let query = serde_urlencoded::from_str::<AllSpendersQuery>(req.uri().query().unwrap_or(""))?;
250+
let query = serde_qs::from_str::<AllSpendersQuery>(req.uri().query().unwrap_or(""))?;
251251
let limit = app.config.spendable_find_limit;
252252
let skip = query
253253
.page
@@ -606,7 +606,7 @@ pub mod validator_message {
606606
validator_id: &Option<ValidatorId>,
607607
message_types: &[String],
608608
) -> Result<Response<Body>, ResponseError> {
609-
let query = serde_urlencoded::from_str::<ValidatorMessagesListQuery>(
609+
let query = serde_qs::from_str::<ValidatorMessagesListQuery>(
610610
req.uri().query().unwrap_or(""),
611611
)?;
612612

@@ -1068,7 +1068,7 @@ mod test {
10681068
.expect("should insert");
10691069

10701070
let build_request = |query: ChannelListQuery| {
1071-
let query = serde_urlencoded::to_string(query).expect("should parse query");
1071+
let query = serde_qs::to_string(&query).expect("should parse query");
10721072
Request::builder()
10731073
.uri(format!("http://127.0.0.1/v5/channel/list?{}", query))
10741074
.extension(DUMMY_CAMPAIGN.channel.clone())

validator_worker/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ thiserror = "^1.0"
3737
# (De)Serialization
3838
serde = { version = "^1.0", features = ["derive"] }
3939
serde_json = "1.0"
40-
serde_urlencoded = "0.7"
40+
serde_qs = "0.9.2"
4141
toml = "0.5"
4242
# CLI
4343
clap = { version = "3.1", features = ["cargo"] }

validator_worker/src/sentry_interface.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -543,7 +543,7 @@ pub mod channels {
543543
let endpoint = sentry_url
544544
.join(&format!(
545545
"v5/channel/list?{}",
546-
serde_urlencoded::to_string(query).expect("Should not fail to serialize")
546+
serde_qs::to_string(&query).expect("Should not fail to serialize")
547547
))
548548
.expect("Should not fail to create endpoint URL");
549549

@@ -608,7 +608,7 @@ pub mod campaigns {
608608
let endpoint = sentry_url
609609
.join(&format!(
610610
"v5/campaign/list?{}",
611-
serde_urlencoded::to_string(query).expect("Should not fail to serialize")
611+
serde_qs::to_string(&query).expect("Should not fail to serialize")
612612
))
613613
.expect("Should not fail to create endpoint URL");
614614

0 commit comments

Comments
 (0)