Replace manual URL encoding with serde_urlencoded library in Aliyun CDN client#10
Merged
daflyinbed merged 4 commits intoaliyunfrom Jan 18, 2026
Merged
Conversation
Co-authored-by: daflyinbed <21363956+daflyinbed@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Update cdn.rs to use serde_urlencoded library
Replace manual URL encoding with serde_urlencoded library in Aliyun CDN client
Jan 17, 2026
daflyinbed
reviewed
Jan 17, 2026
| } | ||
|
|
||
| let form_body = build_form_urlencoded_body(&form_params); | ||
| let form_body = serde_urlencoded::to_string(&form_params) |
…ches Co-authored-by: daflyinbed <21363956+daflyinbed@users.noreply.github.com>
daflyinbed
reviewed
Jan 18, 2026
src/aliyun/cdn.rs
Outdated
| object_type: Option<String>, | ||
|
|
||
| #[serde(rename = "Force", skip_serializing_if = "Option::is_none")] | ||
| force: Option<String>, |
Contributor
Author
There was a problem hiding this comment.
Changed force field to Option for cleaner serialization. Commit 7c3016e
Co-authored-by: daflyinbed <21363956+daflyinbed@users.noreply.github.com>
daflyinbed
added a commit
that referenced
this pull request
Jan 19, 2026
…n Aliyun CDN client (#10) * Initial plan * Replace manual form encoding with serde_urlencoded library Co-authored-by: daflyinbed <21363956+daflyinbed@users.noreply.github.com> * Use struct instead of BTreeMap for form parameters in RefreshObjectCaches Co-authored-by: daflyinbed <21363956+daflyinbed@users.noreply.github.com> * Use bool type for force field instead of String Co-authored-by: daflyinbed <21363956+daflyinbed@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: daflyinbed <21363956+daflyinbed@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Replaced manual form URL encoding implementation in
src/aliyun/cdn.rswith the standardserde_urlencodedlibrary for better reliability and maintainability.Changes
serde_urlencoded = "0.7.1"toCargo.tomlRefreshObjectCachesFormParamsstruct with proper serde field renaming for type-safe URL encodingbuild_form_urlencoded_body()call withserde_urlencoded::to_string()using the new structbuild_form_urlencoded_body()andform_urlencode()helper functionsBefore
After
The standard library handles edge cases and encoding rules more robustly than the custom implementation. Using a dedicated struct instead of BTreeMap provides compile-time type safety and clearer intent. The
forcefield maintains its nativeOption<bool>type for cleaner serialization.Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.