Releases: ubgo/httpreq
Releases · ubgo/httpreq
Release list
v0.2.0
Zero-dependency, stdlib-only. This release turns httpreq from a bare JSON convenience into a complete small HTTP client while keeping the tiny surface and zero deps.
Highlights
Observability (dependency-free)
WithObserver(func(ctx, Trace))— oneTraceper attempt on every path (success, non-2xx, network error, decode error); metadata only, no bodies or headers.WithConnTrace()— DNS/Connect/TLS/TTFB phase timing vianet/http/httptrace.SlogObserver(*slog.Logger, level)— structured logging via stdliblog/slog; failures log at ERROR.
Dump as curl
Curl(ctx, url, opts...)returns the request as a runnablecurlcommand without sending;WithCurl(func(string))logs exactly whatDosends;RequestCurl(*http.Request)renders any request. Headers sorted, shell-quoted, body read without being consumed.
Auth & bodies
WithBasicAuth,WithFormBody(x-www-form-urlencoded),WithUserAgent+ defaulthttpreq/<version>.
Responses
WithResponseBytes(*[]byte)— capture raw non-JSON bodies.WithResponseWriter(io.Writer)— stream large downloads without buffering.WithErrorInto(any)— decode a structured error body on non-2xx.WithExpectStatus(...int)— treat 304 etc. as success.
Escape hatch & bulk setters
WithRequest(func(*http.Request) error)— sign/mutate the built request before send (also runs forCurl).WithHeaders(http.Header),WithQuery(url.Values).
100% test coverage, race-clean, lint-clean. See the CHANGELOG for the full list.
Full changelog: v0.1.0...v0.2.0