intercepted_http 0.2.1
intercepted_http: ^0.2.1 copied to clipboard
A composable HTTP interceptor layer for package:http. Add auth headers, token refresh, retry logic, and logging without replacing your HTTP client.
Changelog #
0.2.1 #
- README updated to reflect v0.2.0 API (
Duration?shouldRetry,http.ResponseonResponse,HttpStatusCodeconstants, response transformation and exponential backoff examples).
0.2.0 #
Breaking changes
HttpInterceptor.shouldRetrynow returnsFuture<Duration?>instead ofFuture<bool>. Returnnullto skip retry,Duration.zeroto retry immediately, or any positiveDurationto retry after a delay. This enables exponential backoff and other delay strategies without extra packages.HttpInterceptor.onResponsenow returnsFuture<http.Response>instead ofFuture<void>. The default implementation returns the response unchanged. Interceptors can now replace the response (e.g. unwrap API envelopes) and each interceptor in the list receives the output of the previous one.
Other changes
InterceptedHttpmaxRetries doc updated to reflectDuration?semantics.- Example updated with exponential backoff and response logging patterns.
- All magic status numbers in library code replaced with
HttpStatusCodeconstants.
0.1.1 #
- Added
HttpStatusCode— named constants for all common HTTP status codes (2xx–5xx). HttpClientExceptiongetters (isUnauthorized,isForbidden,isNotFound,isServerError) now referenceHttpStatusCodeinstead of magic numbers.HttpStatusCodeis exported from the main barrel so consumers can use it directly.
0.1.0 #
- Initial release.
InterceptedHttp— drop-inhttp.Clientwrapper with interceptor support.HttpInterceptor— base class withonRequest,onResponse,onError,shouldRetry.HttpClientException— typed exception for 4xx/5xx responses with JSON message extraction.- Configurable timeout, max retries, and inner client.