You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Sources/ComposableArchitecturePattern/Server+API.swift
+5Lines changed: 5 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -17,9 +17,14 @@ public protocol ServerAPI: Identifiable, Equatable {
17
17
varsupportedReturnObjects:[Codable.Type]?{getset}
18
18
vartimeoutInterval:TimeInterval{getset}
19
19
20
+
/// Initialize with the provided values.
21
+
///
22
+
/// - Note: It is highly encouraged to define your `supportedReturnObjects` to ensure `-supports<T: Codable>(_:)` is able to automatically verify against this.
func request(_ method:HTTPMethod, in environment:ServerEnvironment?, additionalHeaders:[String:String]?, additionalQueries:[URLQueryItem]?, httpBodyOverride httpBody:Data?, timeoutInterval:TimeInterval?)throws->URLRequest
26
+
27
+
/// Whether or not the provided type is supported by the API. Defaults to checking if the type is found in `supportedReturnObjects` or returning `false` if not found.
Copy file name to clipboardExpand all lines: Sources/ComposableArchitecturePattern/Server.swift
+24Lines changed: 24 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -25,9 +25,12 @@ public protocol Server: Actor {
25
25
/// Whether or not to log all activity wtih this server.
26
26
varlogActivity:LogActivity{get}
27
27
28
+
/// All the API's supported by the server.
28
29
varapis:[anyServerAPI]{get}
29
30
31
+
/// Flag to not all the server to send any request that is not explicitly defined in `apis`.
30
32
varblockAllAPIsNotSupported:Bool{get}
33
+
/// All the requests currently being processed.
31
34
varrequestsBeingProcessed:Set<UUID>{getset}
32
35
33
36
varlogger:Logger{get}
@@ -41,18 +44,39 @@ public protocol Server: Actor {
41
44
logActivity:LogActivity
42
45
)
43
46
47
+
/// Sends a GET request and returns the specified value type from the given API.
48
+
///
49
+
/// - Note: The server automatically checks against these values to check whether they're supported by the API or not. For instance, if the specified return type is not supported, a `ServerAPIError.badRequest` error is thrown. If the specified API doesn't support this function, a `ServerAPIError.badRequest` error is thrown.
/// Sends a POST request and returns the specified value type from the given API.
53
+
///
54
+
/// - Note: The server automatically checks against these values to check whether they're supported by the API or not. For instance, if the specified return type is not supported, a `ServerAPIError.badRequest` error is thrown. If the specified API doesn't support this function, a `ServerAPIError.badRequest` error is thrown.
/// Sends a POST request and returns the specified value type from the given API.
58
+
///
59
+
/// - Note: The server automatically checks against these values to check whether they're supported by the API or not. For instance, if the return type of `Bool` is not supported, a `ServerAPIError.badRequest` error is thrown. If the specified API doesn't support this function, a `ServerAPIError.badRequest` error is thrown.
/// Sends a PUT request and returns the specified value type from the given API.
63
+
///
64
+
/// - Note: The server automatically checks against these values to check whether they're supported by the API or not. For instance, if the specified return type is not supported, a `ServerAPIError.badRequest` error is thrown. If the specified API doesn't support this function, a `ServerAPIError.badRequest` error is thrown.
/// Sends a PUT request and returns the specified value type from the given API.
68
+
///
69
+
/// - Note: The server automatically checks against these values to check whether they're supported by the API or not. For instance, if the return type of `Bool` is not supported, a `ServerAPIError.badRequest` error is thrown. If the specified API doesn't support this function, a `ServerAPIError.badRequest` error is thrown.
/// Sends a DELETE request and returns the specified value type from the given API.
73
+
///
74
+
/// - Note: The server automatically checks against these values to check whether they're supported by the API or not. For instance, if the specified return type is not supported, a `ServerAPIError.badRequest` error is thrown. If the specified API doesn't support this function, a `ServerAPIError.badRequest` error is thrown.
/// Sends a DELETE request and returns the specified value type from the given API.
78
+
///
79
+
/// - Note: The server automatically checks against these values to check whether they're supported by the API or not. For instance, if the return type of `Bool` is not supported, a `ServerAPIError.badRequest` error is thrown. If the specified API doesn't support this function, a `ServerAPIError.badRequest` error is thrown.
0 commit comments