Skip to content

Commit 4cb8255

Browse files
committed
Update to reduce required initializer parameters
This also provides default values for `currentEnvironment`, `additionalHTTPHeaders`, and `blockAllAPIsNotSupported`.
1 parent 95e63e8 commit 4cb8255

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

Sources/ComposableArchitecturePattern/Server.swift

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,8 @@ public protocol Server: Actor {
4545

4646
/// Designated initializer
4747
init(
48-
urlSession: URLSession,
4948
environments: [ServerEnvironment],
50-
currentEnvironment: ServerEnvironment?,
51-
additionalHTTPHeaders: [String: String]?,
52-
supportedAPIs: [any ServerAPI],
53-
logActivity: LogActivity
49+
supportedAPIs: [any ServerAPI]
5450
)
5551

5652
/// Sends a GET request and returns the specified value type from the given API.
@@ -119,6 +115,12 @@ public extension Server {
119115
URLSession.shared
120116
}
121117

118+
var currentEnvironment: ServerEnvironment? { nil }
119+
120+
var additionalHTTPHeaders: [String: String]? { nil }
121+
122+
var blockAllAPIsNotSupported: Bool { true }
123+
122124
// GETs
123125
func get<T: Codable>(_ api: any ServerAPI, additionalHeaders: [String: String]? = nil, queries: [URLQueryItem]? = nil, httpBodyOverride httpBody: Data? = nil, timeoutInterval: TimeInterval? = nil, dateDecodingStrategy: JSONDecoder.DateDecodingStrategy = .iso8601, keyDecodingStrategy: JSONDecoder.KeyDecodingStrategy = .useDefaultKeys) async throws -> T {
124126
if self.blockAllAPIsNotSupported {

0 commit comments

Comments
 (0)