rhttp v0.1.0 — resilient HTTP client, zero dependencies
First public release of rhttp: a production-grade HTTP client for Go with built-in resiliency patterns and zero dependencies — Go standard library only.
Highlights
- Middleware architecture — every capability is an
http.RoundTripperdecorator, composed withNew(WithMiddleware(...)). Writing your own middleware is a one-liner with the exportedRoundTripperFunc. - Resiliency —
Timeout,Retrywith pluggable backoff,CircuitBreaker(single-probe half-open, generation-gated state machine), andRateLimit(token bucket). - Retry-After aware — backoff strategies receive the response that triggered the retry; the
WithRetryAfterdecorator honors theRetry-Afterheader (delay-seconds or HTTP-date) on 429/503. - Shared circuit state —
NewCircuitBreakerlets several clients trip together against the same dependency, with observableState(). - Observability —
LoggingandMetricsmiddleware;PathNormalizerbounds metrics label cardinality. - Fluent builder —
client.R()with JSON/XML/form/reader bodies, path and query parameters. Bodies up to 10 MB are buffered so retries can rewind them; larger bodies stream and are sent exactly once. - Error classification —
Classify,IsRetryable,IsTimeout,IsConnectionand friends, plus the opinionatedDecodeJSONhelper.
Performance
Measured 2026-07-25 (linux/amd64, i7-1255U, min of 5 runs; see the README for methodology and caveats):
| ns/op | allocs/op | |
|---|---|---|
| Full middleware stack (no-op transport) | 1030 | 13 |
| As a wrapper vs equivalently configured competitors | 910 | 12 |
| net/http floor (timeout only, no retry) | 1750 | 26 |
| Rate limiter check | 48 | 0 |
| Backoff strategies | <10 | 0 |
Loopback numbers amplify relative differences — against a real network (0.5–500 ms) every client performs the same for practical purposes. Full tables and reproduction steps: benchmarks/REPORT.md.
Quality
- 95.2% statement coverage on the root package; race-clean suite across Go 1.21–1.23 in CI.
- Middleware interaction semantics (timeout budgets, per-attempt deadlines, breaker cutting retries) pinned by tests.
Install
go get github.com/oswaldom-code/rhttp@v0.1.0
Full changelog: CHANGELOG.md