Skip to content

Release 0.2.0: percent-encode path params, add with_client, derive Clone - #3

Merged
azeemshaik025 merged 1 commit into
mainfrom
feat/v0.2.0
Aug 9, 2026
Merged

Release 0.2.0: percent-encode path params, add with_client, derive Clone#3
azeemshaik025 merged 1 commit into
mainfrom
feat/v0.2.0

Conversation

@azeemshaik025

Copy link
Copy Markdown
Owner

Summary

Non-breaking 0.2.0 — one correctness fix and two additive ergonomics wins. No existing API changes; new keeps the same signature.

Fixed

  • Path parameters are now percent-encoded (RFC 3986 unreserved set). A value like 1/2 or a?b previously 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 downstream Cargo.tomls.

Added

  • with_client(url, [auth], client, timeout) — supply your own reqwest::Client so one connection pool, TLS config, proxy, and set of default headers can be shared across clients. new now delegates to it.
  • #[derive(Clone)] on the generated struct — cheap (reqwest::Client is Arc-backed), so it clones into spawned tasks.

Docs

  • README: Constructors section for new/with_client, Clone noted in the generated-code list.
  • advanced.rs demonstrates sharing one pool across two service clients; basic.rs points at the with_client alternative.
  • CHANGELOG [0.2.0] entry.

Tests

All 23 tests pass (19 pre-existing unchanged + 4 new); cargo fmt --check and cargo clippy --all-targets -- -D warnings clean.

New test Proves
test_path_params_are_percent_encoded 1/2 → single segment; a raw / would miss the mock
test_with_client_uses_caller_config a default header on the injected client reaches the server — its pool/TLS config is the one in effect
test_cloned_client_still_works a clone issues a real request; the original still works after
test_with_client_constructor with_client builds a working client

The 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 breaking 0.3.0 and/or DSL design, so they're intentionally out of scope here.

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.
@azeemshaik025
azeemshaik025 merged commit e1f9875 into main Aug 9, 2026
1 check passed
@azeemshaik025
azeemshaik025 deleted the feat/v0.2.0 branch August 9, 2026 05:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant