http_toolkit 2.0.0+1
http_toolkit: ^2.0.0+1 copied to clipboard
Collection of missing features for the Dart HTTP package.
Changelog #
2.0.0+1 #
- Minor documentation updates
2.0.0 #
Breaking Changes #
BackoffStrategy: RenamedgetDelaytogetDelayDurationfor clarity.RetryMiddleware.whenError: Signature changed frombool Function(Object error)tobool Function(Object error, int attempt, Duration nextAttempt).RetryMiddleware.whenResponse: Signature changed frombool Function(BaseResponse response)tobool Function(BaseResponse response, int attempt, Duration totalDuration).- Removed
ClientExtensions.getWith: UsegetDecodedwith appropriate parameters instead.
New Features #
-
ResponseValidator: A new utility class providing reusable HTTP response validation functions:statusCode(response, code)- Validates specific status codesuccess(response)- Validates 2xx range (200-299)created(response)- Validates 201 statussuccessOrNoContent(response)- Validates 200 or 204jsonContentType(response)- Validatesapplication/jsoncontent-typenotEmpty(response)- Validates non-empty response body
-
*DecodedClient Extensions: New type-safe JSON decoding methods onhttp.Client:getDecoded<R, T>- GET with JSON mapping and optional validationpostDecoded<R, T>- POST with JSON mapping and optional validationputDecoded<R, T>- PUT with JSON mapping and optional validationpatchDecoded<R, T>- PATCH with JSON mapping and optional validationdeleteDecoded<R, T>- DELETE with JSON mapping and optional validation
-
Type Aliases: New
types.dartexports:ResponseBodyMapper<R, T>- Function type for mapping response bodiesResponseValidator- Function type for validating responses
Improvements #
RetryMiddleware: Enhanced callback signatures provide access to attempt count and delay duration for better observability and control over retry logic.- Example:
- Updated with
RetryMiddlewaredemo showcasing new callback parameters. - Added example usage of
getDecoded<R, T>.
- Updated with
1.0.0+1 #
- Minor fixes and updates to docs.
1.0.0 #
- Initial release.
- Client: A robust HTTP client wrapper compatible with key
httppackage logic. - Middleware: New
Middlewareinterface for structured request/response processing. - Retry:
RetryMiddlewarewith configurableBackoffStrategy(Exponential, Linear, Fixed). - Logger:
LoggerMiddlewarewith support for logging headers and bodies, usingprintby default. - Auth:
BearerAuthMiddlewareandBasicAuthMiddleware. - BaseUrl:
BaseUrlMiddlewarefor convenient URL handling. - Interceptors: Lightweight hooks for
onRequest,onResponse, andonError. - Extensions: Useful extensions for
http.Response(JSON parsing) andhttp.Client. - Added
ClientExtensionsfor easier query parameter handling.