https://github.com/sunsided/query-string-builder
A query string builder for percent encoding key-value pairs in Rust
https://github.com/sunsided/query-string-builder
http query-string query-string-builder rust
Last synced: 3 months ago
JSON representation
A query string builder for percent encoding key-value pairs in Rust
- Host: GitHub
- URL: https://github.com/sunsided/query-string-builder
- Owner: sunsided
- License: eupl-1.2
- Created: 2023-07-07T19:58:47.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-06-07T22:37:37.000Z (about 1 year ago)
- Last Synced: 2025-03-17T00:09:12.084Z (4 months ago)
- Topics: http, query-string, query-string-builder, rust
- Language: Rust
- Homepage: https://crates.io/crates/query-string-builder
- Size: 77.1 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.md
Awesome Lists containing this project
README
# A query string builder for percent encoding key-value pairs
[](https://crates.io/crates/query-string-builder)
[](https://crates.io/crates/query-string-builder)
[](https://codecov.io/gh/sunsided/query-string-builder)This is a tiny helper crate for simplifying the construction of URL query strings.
The initial `?` question mark is automatically prepended.## Example
```rust
use query_string_builder::QueryString;fn main() {
let qs = QueryString::simple()
.with_value("q", "apple")
.with_value("tasty", true)
.with_value("weight", 70.0)
.with_opt_value("color", None::)
.with_opt_value("category", Some("fruits and vegetables?"));assert_eq!(
format!("https://example.com/{qs}"),
"https://example.com/?q=apple&tasty=true&weight=70.0&category=fruits%20and%20vegetables?&tasty=true"
);
}
```