Interceptor
open class Interceptor : @unchecked Sendable, RequestInterceptor
RequestInterceptor
which can use multiple RequestAdapter
and RequestRetrier
values.
-
All
RequestAdapter
s associated with the instance. These adapters will be run until one fails.Declaration
Swift
public let adapters: [any RequestAdapter]
-
All
RequestRetrier
s associated with the instance. These retriers will be run one at a time until one triggers retry.Declaration
Swift
public let retriers: [any RequestRetrier]
-
Creates an instance from
AdaptHandler
andRetryHandler
closures.Declaration
Swift
public init(adaptHandler: @escaping AdaptHandler, retryHandler: @escaping RetryHandler)
Parameters
adaptHandler
AdaptHandler
closure to be used.retryHandler
RetryHandler
closure to be used. -
Creates an instance from
RequestAdapter
andRequestRetrier
values.Declaration
Swift
public init(adapter: any RequestAdapter, retrier: any RequestRetrier)
Parameters
adapter
RequestAdapter
value to be used.retrier
RequestRetrier
value to be used. -
Creates an instance from the arrays of
RequestAdapter
andRequestRetrier
values.Declaration
Swift
public init(adapters: [any RequestAdapter] = [], retriers: [any RequestRetrier] = [], interceptors: [any RequestInterceptor] = [])
Parameters
adapters
RequestAdapter
values to be used.retriers
RequestRetrier
values to be used.interceptors
RequestInterceptor
s to be used. -
Declaration
Swift
@preconcurrency open func adapt(_ urlRequest: URLRequest, for session: Session, completion: @escaping @Sendable (Result<URLRequest, any Error>) -> Void)
-
Declaration
Swift
@preconcurrency open func adapt(_ urlRequest: URLRequest, using state: RequestAdapterState, completion: @escaping @Sendable (Result<URLRequest, any Error>) -> Void)
-
Declaration
Swift
@preconcurrency open func retry(_ request: Request, for session: Session, dueTo error: any Error, completion: @escaping @Sendable (RetryResult) -> Void)