handle library

A simple library for composing HTTP clients, and creating services to make HTTP requests.

Classes

ConverterClient Clients
CurrentFirstPathJoinStrategy
A path join strategy that returns path segments where the path segments of currentUri is ordered before otherUri passed to it.
CurrentOnlyPathJoinStrategy
A path join strategy that only returns the currentUri passed to it.
DefaultPathJoinStrategy
Returns an array of path segments.
Handle Clients
A client that allows retrying HTTP request with different request on response or errors
HandleClient Clients
A client that allows retrying HTTP request with different request on response or errors
HandleInterface
HttpService<T extends Client> Get started Configuration Services
A service that uses client for making requests. It is recommend to extend this class and add your method and use the client to make requests in the methods to the server.
HttpServiceConfig<T extends Client>
InnerClientWrapper
An abstract class that exposes the inner Client to sub-classes from inner.
InterceptorClient Clients
JsonDeserializerOf<T extends Object>
JsonModelSerializer Get started Configuration
A class that serializes and deserializes JSON objects to and from Dart classes.
OtherFirstPathJoinStrategy
A path join strategy that returns path segments where the path segments of otherUri is ordered before currentUri passed to it.
OtherOnlyPathJoinStrategy
A path join strategy that only returns the otherUri passed to it.
PathJoinStrategy
Returns a path segment by resolving (or merging) otherUri and currentUri. Implementors of this class must resolve the 2 urls based on a strategy so that those classes can be used as a PathJoinCallback.
RequestClient Get started Clients
A client that overrides url, headers of the request.
RequestConverterClient Clients
RequestInterceptorClient Clients
ResponseConverterClient Clients
ResponseInterceptorClient Clients
RestClient Get started Configuration Clients
Creates a client that returns RestResponse for a request.
RestResponse
A HTTP response for REST HTTP apis.
RestService Get started Configuration Services
A service that can be used to make requests to a JSON Api. It wraps the client with RestClient if necessary to return a RestResponse. It is recommended to extend this class and add your methods to it where you use client to make requests.
RestServiceConfig
WrapperClient Configuration Clients Error handling
An abstract class that wraps a Client.

Extensions

CopyRequestExtension on BaseRequest
FinalizedBodyStreamExtension on FinalizedBodyStream
ResponseFuture on Future<Response> Extensions Error handling
Extensions on Future<http.Response> to allow usage of some methods from RestResponse as a shortcut.
StreamedResponseFuture on Future<StreamedResponse> Extensions Error handling

Constants

HANDLE_RETRY_MAX_LIMIT → const int

Functions

joinUrls(Uri other, Uri? current, PathJoinCallback onJoinPath) Uri
Returns a url after joining current and other.
updateHeaderIfAbsent(Map<String, String> requestHeaders, MapEntry<String, String> header) bool

Typedefs

DelayCallback = Duration Function(int retryCount)
FinalizedBodyStream = Stream<List<int>>
FinalizedBodyStreamCallback = FinalizedBodyStream Function()
FromJsonCallback<T> = T? Function(dynamic json)
NeedsHeaderUpdate = bool Function(Map<String, String> requestHeaders, MapEntry<String, String> header)
PathJoinCallback = Iterable<String> Function(Uri otherUrl, Uri currentUrl)
PathJoinStrategyCallback = PathJoinStrategy Function(Uri otherUri, Uri currentUri)
RequestConverterCallback = FutureOr<BaseRequest> Function(BaseRequest)
RequestInterceptorCallback = FutureOr<void> Function(BaseRequest)
ResponseConverterCallback = FutureOr<StreamedResponse> Function(StreamedResponse)
ResponseInterceptorCallback = FutureOr<void> Function(StreamedResponse)
WhenCallback = FutureOr<bool> Function(BaseResponse response, int retryCount)
WhenErrorCallback = FutureOr<bool> Function(Object object, StackTrace stackTrace, int retryCount)
WhenRequestCallback = FutureOr<BaseRequest> Function(BaseRequest originalRequest, BaseRequest lastRequest, FinalizedBodyStreamCallback bodyStream, BaseResponse? response, int retryCount)
WhenRetriedCallback = FutureOr<void> Function(BaseRequest request, BaseResponse? response, int retryCount)
WrapperClientBuilder<T extends Client> = T Function(Client client)