Classes
The following classes are available globally.
-
An
See moreHTTPClientthat usesAlamofirefor sending requests.Declaration
Swift
public class AlamofireClient : HTTPClient -
RestingClientis the core class ofRestingKit. It allows sending requests and receiving their responses as promises through a high-level API.The
RestingClientis configured with the following components:baseUrl: The base URL of the server we want to connect. One client can only connect to a single base URL. Therefore, if you wish to use multiple APIs, you should use different clients for each of them.decoder: The decoder to use for decoding responses.requestConverter: The converter to use for convertingRestingRequests toHTTPRequests.interceptors: The interceptors to run for each request and response.httpClient: The client responsible for sending the request and receiving its response.
There are two function families within the class:
perform(_:)andupload(_:), each with several overloads for convenience. Even though they do the same thing in the core, The way to achieve their goal is different.perform(_:)sends the request by loading the request body into memory, whileupload(_:)streams the body from a file without loading it.upload(_:)also allows tracking upload progress. For most requestsperform(_:)should be good enough, but for cases when the request body is expected to be large,upload(_:)should be preferred.The process within a
RestingClientis the following:- The request converter converts the
RestingRequestinto anHTTPRequest. - The interceptors are run with the produced
HTTPRequestin the order provided. At this point, one of the interceptors might decide to modify the request or stop the execution chain by returning a response or and error. - If the interceptors doesn’t block the chain, the
HTTPClientis called to perform the actual request. - The response from
HTTPClientis passed to the interceptors. At this point, an interceptor might decide to change the response or recover from an error. - The response is then converted into an
HTTPResponseby decoding the response body.
Cases when request promises might fail:
- The encoding of the request has failed.
- The decoding of the response has faied.
- Networking errors.
- The response status was not 2xx.
- An interceptor decided to raise an error.
Declaration
Swift
open class RestingClient -
An interceptor that logs requests and responses, including errors if present.
See moreDeclaration
Swift
open class RequestResponseLoggingInterceptor : RestingInterceptor -
A default implementation of
See moreHeaderProvidersupporting dynamic header provisioning.Declaration
Swift
public class RestingHeaderProvider : HeaderProvider -
A default implementation of
See moreHeaderProvidersupporting dynamic variable provisioning.Declaration
Swift
public class RestingPathVariableProvider : PathVariableProvider -
Represents a high-level HTTP Request.
See moreDeclaration
Swift
open class RestingRequest<RequestType, ResponseType>Parameters
RequestTypeThe type of the request parameters.
ResponseTypeThe type of response.
-
x A
RequestConverterthat supports:- Path templating using GRMustache.swift
- Streamed requests
Declaration
Swift
public class RestingRequestConverter : RequestConverter -
Represents a lower-level HTTP Response.
See moreDeclaration
Swift
public class HTTPDataResponse -
An error thrown when a response status code is not 2xx.
See moreDeclaration
Swift
public class HTTPError : Error -
Represents a higher-level HTTP Response.
See moreDeclaration
Swift
public class HTTPResponse<BodyType> : HTTPResponseType -
An object that encodes
See moreEncodableobjects intoMultipartFormData.Declaration
Swift
public class MultipartFormDataEncoder -
An object that encodes
See moreEncodableobjects into an array ofURLQueryItem.Declaration
Swift
public class QueryParameterEncoder -
Represents a file to be sent through a multipart/form-data request.
See moreWarning
Even tough the class isEncodable, it is supposed to be encoded withMultipartFormDataEncoder. Encoding with a different encoder will result in an undefined result.Declaration
Swift
public class MultipartFile : Encodable -
A wrapper around PromiseKit’s Promise class that supports progress callbacks.
See moreDeclaration
Swift
public class ProgressablePromise<T> : AnyProgressablePromise
Classes Reference