The following classes are available globally.

  • Introduction

    An object used to execute Requestable(s)

    Basic usage might look like this:

    struct MyRequest: Requestable {
    let manager = RequestManager(host: "")
    let request = MyRequest()
    let cancellable = manager.makeRequest(request,
                                          retries: 3,
                                          sla: .seconds(120),
                                          on: DispathQueue.main)
        .sink { responseBody in


    The publisher created by the makeRequest methods return a RequestResponse and a RequestError. See the documentation on both of these generic types for more information.

    Request Lifecycle & Error Handling

    The request lifecycle creates many different points of failure, and provides users with a robust error model to determin what went wrong and where

    1. The request is created. Possible failures inlcude an invalid URL, or a failure to encode the RequestBody, if one is present
    2. The request is excecuted. Possible failures include a broken network connection, a missing host, or a timeout.
    3. The request is parsed. The only possible failure here would be an attempt to decode the response data
    4. The request is validated. The provided ResponseValidator examines the response’s headers, status code, and body and choose to manipulate it or throw and error. See the “Validation step below for more information.

    When the manager encounters any of the errors describer above, you can choose to retry to request. The number of retries is specified as a paramater in the makeRequest<T, S>(_:retries:sla:on:fallback:) method. You can also specify an SLA by which all retries must complete, and an optional fallback response to use. The request object itself can also contain a fallback response.

    Additional Headers

    In addition to the headers specified in the Requestable, you can have the manager inject its own headers on every request it makes. This can be useful for handling things like authentication.

    let manager = RequestManager(host: "")
    manager.additionalHeaders = [.authorization, .authorization(username: "myusername", password: "mypassword"]
    // these headers will be injected into every request

    Default Headers

    RequestManager automatically injects User-Agent, Accept-Encoding, and Accept-Language headers into every request it makes by default. You can disable this behavior by setting the shouldInjectDefaultHeaders property to false


    RequestManager support logging via Apple Unified Logging To enable this, use one of the initializers that accept a log subsystem or an OSLog instance

    See more



    open class RequestManager