TNConfiguration
public final class TNConfiguration
extension TNConfiguration: NSCopying
A configuration class that can be used with TNEnvironment, TNRouteConfiguration and TNRequest. A configuration object follows the following rules:
- When a TNConfiguration object is passed to a TNEnvironment, each TNRouter (with its routes) will inherit this configuration.
- When a TNConfiguration object is passed to TNRouter, all its routes will inherit this configuration.
-
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: TNRequestBodyType?
-
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 TNRouteConfiguration.
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: TNMockDelayType?
-
Specifies a key decoding strategy. Take a look at: https://developer.apple.com/documentation/foundation/jsondecoder/keydecodingstrategy
Declaration
Swift
public var keyDecodingStrategy: JSONDecoder.KeyDecodingStrategy?
-
Error handlers that will be used as a fallback after request failure.
Declaration
Swift
public var errorHandlers: [TNErrorHandlerProtocol.Type]?
-
Request middlewares
Declaration
Swift
public var requestMiddlewares: [TNRequestMiddlewareProtocol.Type]?
-
init(cachePolicy:
timeoutInterval: requestBodyType: certificatePaths: verbose: headers: mockDataBundle: mockDataEnabled: mockDelay: keyDecodingStrategy: errorHandlers: requestMiddlewares: ) Default initializer of TNConfiguration
Declaration
Swift
public init(cachePolicy: URLRequest.CachePolicy? = nil, timeoutInterval: TimeInterval? = nil, requestBodyType: TNRequestBodyType? = nil, certificatePaths: [String]? = nil, verbose: Bool? = nil, headers: [String: String]? = nil, mockDataBundle: Bundle? = nil, mockDataEnabled: Bool? = nil, mockDelay: TNMockDelayType? = nil, keyDecodingStrategy: JSONDecoder.KeyDecodingStrategy? = nil, errorHandlers: [TNErrorHandlerProtocol.Type]? = nil, requestMiddlewares: [TNRequestMiddlewareProtocol.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 TNRouteConfiguration.
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.
requestMiddlewares
Request middlewares. For example see Examples/Communication/Middlewares/CryptoMiddleware.swift
-
NSCopying implementation, used for cloning TNConfiguration objects.
Declaration
Swift
public func copy(with zone: NSZone? = nil) -> Any