Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Alamofire's EventMonitors #27

Merged
merged 2 commits into from
Jun 29, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions Sources/ApexyAlamofire/AlamofireClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,14 @@ open class AlamofireClient: Client {
/// - completionQueue: The serial operation queue used to dispatch all completion handlers. `.main` by default.
/// - publicKeys: Dictionary with 1..n public keys used for SSL-pinning: ["example1.com": [PK1], "example2": [PK2, PK3]].
/// - responseObserver: The closure to be called after each response.
/// - eventMonitors: Alamofire `EventMonitor`s used by the instance. `[]` by default.
public init(
requestInterceptor: RequestInterceptor,
configuration: URLSessionConfiguration,
completionQueue: DispatchQueue = .main,
publicKeys: [String: [SecKey]] = [:],
responseObserver: ResponseObserver? = nil) {
responseObserver: ResponseObserver? = nil,
eventMonitors: [EventMonitor] = []) {

var securityManager: ServerTrustManager?
/// All requests will cancelled if `ServerTrustManager` will initialized with empty evaluators
Expand All @@ -61,7 +63,8 @@ open class AlamofireClient: Client {
self.sessionManager = Session(
configuration: configuration,
interceptor: requestInterceptor,
serverTrustManager: securityManager)
serverTrustManager: securityManager,
eventMonitors: eventMonitors)
self.responseObserver = responseObserver
}

Expand All @@ -73,18 +76,21 @@ open class AlamofireClient: Client {
/// - completionQueue: The serial operation queue used to dispatch all completion handlers. `.main` by default.
/// - publicKeys: Dictionary with 1..n public keys used for SSL-pinning: ["example1.com": [PK1], "example2": [PK2, PK3]].
/// - responseObserver: The closure to be called after each response.
/// - eventMonitors: Alamofire `EventMonitor`s used by the instance. `[]` by default.
public convenience init(
baseURL: URL,
configuration: URLSessionConfiguration,
completionQueue: DispatchQueue = .main,
publicKeys: [String: [SecKey]] = [:],
responseObserver: ResponseObserver? = nil) {
responseObserver: ResponseObserver? = nil,
eventMonitors: [EventMonitor] = []) {
self.init(
requestInterceptor: BaseRequestInterceptor(baseURL: baseURL),
configuration: configuration,
completionQueue: completionQueue,
publicKeys: publicKeys,
responseObserver: responseObserver)
responseObserver: responseObserver,
eventMonitors: eventMonitors)
}

/// Send request to specified endpoint.
Expand Down