Skip to content

Commit a46f3ce

Browse files
Allan LangAllan Lang
authored andcommitted
Move http configuration options to Constants
1 parent 322cd6d commit a46f3ce

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

Tree Tracker/Constants.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,10 @@ enum Constants {
1313
static let cloudName = Secrets.cloudinaryCloudName
1414
static let uploadPresetName = Secrets.cloudinaryUploadPresetName
1515
}
16+
enum Http {
17+
static let requestWaitsForConnectivity = true
18+
static let requestTimeoutSeconds: TimeInterval = 30
19+
static let requestRetryDelaySeconds = 5
20+
static let requestRetryLimit = 3
21+
}
1622
}

Tree Tracker/Services/AlamofireApi.swift

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,12 @@ final class AlamofireApi: Api {
2828
self.logger = logger
2929

3030
let sessionConfig = URLSessionConfiguration.af.default
31-
sessionConfig.timeoutIntervalForRequest = 30
32-
sessionConfig.waitsForConnectivity = true
31+
sessionConfig.timeoutIntervalForRequest = Constants.Http.requestTimeoutSeconds
32+
sessionConfig.waitsForConnectivity = Constants.Http.requestWaitsForConnectivity
3333

3434
self.session = Session(configuration: sessionConfig,
35-
interceptor: RetryingRequestInterceptor(retryDelaySecs: 5, maxRetries: 3))
35+
interceptor: RetryingRequestInterceptor(retryDelaySecs: Constants.Http.requestRetryDelaySeconds,
36+
maxRetries: Constants.Http.requestRetryLimit))
3637

3738
}
3839

0 commit comments

Comments
 (0)