Configuration

public final class Configuration
extension Configuration: NSCopying

A configuration class that can be used with Environment, Repository, Endpoint and Request. A configuration object follows the following rules:

  1. When a Configuration object is passed to an Environment, each Repository with its Endpoints and requests will inherit this configuration.
  2. When a Configuration object is passed to Repository, all its Endpoints and Requests will inherit this configuration.

Public properties

  • The cache policy of the request.

    Declaration

    Swift

    public var cachePolicy: URLRequest.CachePolicy?
  • The timeout interval of the request.

    Declaration

    Swift

    public var timeoutInterval: TimeInterval?
  • The request body type of the request. Can be either .xWWWFormURLEncoded or .JSON.

    Declaration

    Swift

    public var requestBodyType: RequestBodyType?
  • The certificate file paths used for certificate pining.

    Declaration

    Swift

    public var certificatePaths: [String]? { get set }
  • Enables or disables debug mode.

    Declaration

    Swift

    public var verbose: Bool?
  • Additional headers of the request. They will be merged with the headers specified in EndpointConfiguration.

    Declaration

    Swift

    public var headers: [String : String]?
  • The Bundle object of mock data used when useMockData is true.

    Declaration

    Swift

    public var mockDataBundle: Bundle?
  • Enables or disables request mocking.

    Declaration

    Swift

    public var mockDataEnabled: Bool?
  • Specifies a delay when mock data is used.

    Declaration

    Swift

    public var mockDelay: MockDelayRange?
  • Declaration

    Swift

    public var keyDecodingStrategy: JSONDecoder.KeyDecodingStrategy?
  • Error handlers that will be used as a fallback after request failure.

    Declaration

    Swift

    public var interceptors: [InterceptorProtocol.Type]?
  • Request middleware

    Declaration

    Swift

    public var requestMiddleware: [RequestMiddlewareProtocol.Type]?

Initializers

  • Default initializer of Configuration

    Declaration

    Swift

    public init(cachePolicy: URLRequest.CachePolicy? = nil,
                timeoutInterval: TimeInterval? = nil,
                requestBodyType: RequestBodyType? = nil,
                certificatePaths: [String]? = nil,
                verbose: Bool? = nil,
                headers: [String: String]? = nil,
                mockDataBundle: Bundle? = nil,
                mockDataEnabled: Bool? = nil,
                mockDelay: MockDelayRange? = nil,
                keyDecodingStrategy: JSONDecoder.KeyDecodingStrategy? = nil,
                interceptors: [InterceptorProtocol.Type]? = nil,
                requestMiddleware: [RequestMiddlewareProtocol.Type]? = nil)

    Parameters

    cachePolicy

    The cache policy of the request.

    timeoutInterval

    The timeout interval of the request.

    requestBodyType

    The request body type of the request. Can be either .xWWWFormURLEncoded or .JSON.

    certificatePaths

    The certificate file paths used for certificate pining.

    verbose

    Enables or disables debug mode.

    headers

    Additional headers of the request. Will be merged with the headers specified in EndpointConfiguration.

    mockDataBundle

    The Bundle object of mock data used when useMockData is true.

    mockDataEnabled

    Enables or disables request mocking.

    mockDelay

    Specifies a delay when mock data is used.

    keyDecodingStrategy

    // Specifies a key decoding strategy. Take a look, at: https://developer.apple.com/documentation/foundation/jsondecoder/keydecodingstrategy

    errorHandlers

    Error handlers that will be used as a fallback after request failure.

    requestMiddleware

    Request middleware. For example see Examples/Communication/Middleware/CryptoMiddleware.swift

  • NSCopying implementation, used for cloning Configuration objects.

    Declaration

    Swift

    public func copy(with zone: NSZone? = nil) -> Any