HTTPHandler

public class HTTPHandler : HTTPHandlerProtocol

HTTPHandler is a default implementation of HTTP REST client.

Important

This is a Public Preview API. It may be changed or removed at any time.

Public

  • Entry point for additional query items for the provided request.

    Declaration

    Swift

    public weak var queryItemsProvider: AdditionalQueryItemProvider?
  • Performs the given HTTPHandlerRequestProtocol. When the request is completed, it tries to decode the response using the HTTPHandlerResponseDecoder and calls the completion block.

    • Example: let httpClient = HTTPHandler(baseURL: API_URL) let request = BatchRoutingRequest<RoutingRequest>(routeQueries: query) httpClient.make(request: request) { (result: Result<BatchRoutingResponse, Error>, _: Data?) in //raw data is unused switch result { case let .success(response): //handle response case let .failure(error): //handle error } }

    Declaration

    Swift

    public func make<T>(
        request: HTTPHandlerRequestProtocol,
        decoder: HTTPHandlerResponseDecoder,
        completion: @escaping (Result<T, Error>, Data?) -> ()
    ) where T: Decodable

    Parameters

    request

    The http request.

    decoder

    The HTTPHandlerResponseDecoder implementation that will be used to transform the response Data to a given T.

    completion

    The completion closure will be called after the response to the request has been processed. The raw data received is represented by Data? in the completion.

  • Cancels all current requests.

    Declaration

    Swift

    public func cancelPendingRequests()

HTTPHandler