Release 0.2.0: percent-encode path params, add with_client, derive Clone - #3
Merged
Conversation
Fixed: - Path parameters are now percent-encoded (RFC 3986 unreserved set), so a value like `1/2` or `a?b` stays inside its URL segment instead of breaking out. Added: - `with_client(url, [auth], client, timeout)` constructor so a caller-supplied `reqwest::Client` — and its connection pool, TLS config, proxy, and default headers — can be shared across clients. `new` now delegates to it. - The generated client struct derives `Clone` (cheap; `reqwest::Client` is Arc-backed). Docs & tests: - README documents both constructors and Clone; CHANGELOG entry for 0.2.0. - Added tests proving path params are encoded, `with_client` uses the caller's client config, and clones remain functional. - advanced.rs demonstrates sharing one pool across two service clients.
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.
Summary
Non-breaking
0.2.0— one correctness fix and two additive ergonomics wins. No existing API changes;newkeeps the same signature.Fixed
1/2ora?bpreviously went into the URL verbatim and could break out of its path segment; it's now encoded (1%2F2,a%3Fb). Encoding is done with a tiny dependency-free helper — nothing new lands in downstreamCargo.tomls.Added
with_client(url, [auth], client, timeout)— supply your ownreqwest::Clientso one connection pool, TLS config, proxy, and set of default headers can be shared across clients.newnow delegates to it.#[derive(Clone)]on the generated struct — cheap (reqwest::ClientisArc-backed), so it clones into spawned tasks.Docs
Constructorssection fornew/with_client,Clonenoted in the generated-code list.advanced.rsdemonstrates sharing one pool across two service clients;basic.rspoints at thewith_clientalternative.[0.2.0]entry.Tests
All 23 tests pass (19 pre-existing unchanged + 4 new);
cargo fmt --checkandcargo clippy --all-targets -- -D warningsclean.test_path_params_are_percent_encoded1/2→ single segment; a raw/would miss the mocktest_with_client_uses_caller_configtest_cloned_client_still_workstest_with_client_constructorwith_clientbuilds a working clientThe pre-existing
test_get_with_path_params(id=123→ still one segment) confirms encoding didn't regress ordinary values.Deferred to a later breaking release
Error-body capture,
Duration-typed timeout,#[non_exhaustive]error enum, and typed error bodies (the standout feature) — all need a breaking0.3.0and/or DSL design, so they're intentionally out of scope here.