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: README.md
+50-11Lines changed: 50 additions & 11 deletions
Original file line number
Diff line number
Diff line change
@@ -7,9 +7,10 @@ Network layer for running requests like GET, POST, PUT, DELETE etc customizable
7
7
8
8
## Features
9
9
-[x] Multiplatform
10
-
-[x] You have fasttrack functions to make requests immediately by url or build the infrastructure configuration that suits you
10
+
-[x] You have fast-track functions to make requests immediately by url or build the infrastructure configuration that suits you
11
11
-[x] Stand alone package without any dependencies using just Apple's facilities
12
12
-[x] Set up amount of attempts(retry) with **"Exponential backoff"** or **"Constant backoff"** strategy if request fails. Exponential backoff is a strategy in which you increase the delays between retries. Constant backoff is a strategy when delay between retries is a constant value
13
+
-[x] Different strategies to validate Data or URLResponse
13
14
-[x] Customizable for different requests schemes from classic **CRUD Rest** to what suits to you
14
15
-[x] Customizable in terms of URLSession
15
16
-[x] Customizable in terms of URLSessionTaskDelegate, URLSessionDelegate
@@ -36,6 +37,13 @@ Network layer for running requests like GET, POST, PUT, DELETE etc customizable
36
37
tryawait Http.Delete.from(url)
37
38
```
38
39
40
+
Fast-track functions return **(Data, URLResponse)** if you need to validate statusCode you can use Check yout different trategies **Http.Validate.Status** to validate status code
@@ -83,16 +96,18 @@ Network layer for running requests like GET, POST, PUT, DELETE etc customizable
83
96
### Custom request
84
97
85
98
```swift
86
-
/// Send custom request based on the specific request instance
87
-
/// - Parameters:
88
-
/// - request: A URL load request that is independent of protocol or URL scheme
89
-
/// - retry: ``RetryService.Strategy`` Default value .exponential with 5 retry and duration 2.0 sec
90
-
/// - taskDelegate: A protocol that defines methods that URL session instances call on their delegates to handle task-level events
91
-
publicfuncsend<T>(
92
-
withrequest : URLRequest,
93
-
retrystrategy : RetryService.Strategy,
94
-
_taskDelegate: ITaskDelegate?=nil
95
-
) asyncthrows-> Http.Response<T> where T :Decodable
99
+
/// Send custom request based on the specific request instance
100
+
/// - Parameters:
101
+
/// - request: A URL load request that is independent of protocol or URL scheme
102
+
/// - retry: ``RetryService.Strategy`` strategy Default value .exponential with 5 retry and duration 2.0
103
+
/// - validate: Set of custom validate fun ``Http.Validate`` For status code like an example Default value to validate statusCode == 200 You can set up diff combinations check out ``Http.Validate.Status``
104
+
/// - taskDelegate: A protocol that defines methods that URL session instances call on their delegates to handle task-level events
Copy file name to clipboardExpand all lines: Sources/async-http-client/proxy/http/Proxy.swift
+20-5Lines changed: 20 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -35,12 +35,14 @@ public extension Http{
35
35
/// - query: An array of name-value pairs
36
36
/// - headers: A dictionary containing all of the HTTP header fields for a request
37
37
/// - retry: Amount of attempts Default value .exponential with 5 retry and duration 2.0
38
+
/// - validate: Set of custom validate fun ``Http.Validate`` For status code like an example Default value to validate statusCode == 200 You can set diff combinations check out ``Http.Validate.Status``
38
39
/// - taskDelegate: A protocol that defines methods that URL session instances call on their delegates to handle task-level events
/// - headers: A dictionary containing all of the HTTP header fields for a request
62
64
/// - retry: Amount of attempts Default value .exponential with 5 retry and duration 2.0
65
+
/// - validate: Set of custom validate fun ``Http.Validate`` For status code like an example Default value to validate statusCode == 200 You can set diff combinations check out ``Http.Validate.Status``
63
66
/// - taskDelegate: A protocol that defines methods that URL session instances call on their delegates to handle task-level events
/// - headers: A dictionary containing all of the HTTP header fields for a request
85
89
/// - retry: Amount of attempts Default value .exponential with 5 retry and duration 2.0
90
+
/// - validate: Set of custom validate fun ``Http.Validate`` For status code like an example Default value to validate statusCode == 200 You can set diff combinations check out ``Http.Validate.Status``
86
91
/// - taskDelegate: A protocol that defines methods that URL session instances call on their delegates to handle task-level events
/// - headers: A dictionary containing all of the HTTP header fields for a request
113
119
/// - retry: Amount of attempts Default value .exponential with 5 retry and duration 2.0
120
+
/// - validate: Set of custom validate fun ``Http.Validate`` For status code like an example Default value to validate statusCode == 200 You can set diff combinations check out ``Http.Validate.Status``
114
121
/// - taskDelegate: A protocol that defines methods that URL session instances call on their delegates to handle task-level events
115
122
publicfunc put<T, V :Encodable>(
116
123
path:String,
117
124
body :V?=nil,
118
125
query :Query?=nil,
119
126
headers :Headers?=nil,
120
127
retry :UInt=1,
128
+
validate :[Http.Validate]=[.status(.const(200))],
121
129
taskDelegate:ITaskDelegate?=nil
122
130
)asyncthrows
123
131
->Http.Response<T>where T:Decodable
@@ -133,7 +141,7 @@ public extension Http{
133
141
request.setValue(content, forHTTPHeaderField:"Content-Type") // for PUT
/// - headers: A dictionary containing all of the HTTP header fields for a request
144
152
/// - retry: Amount of attempts Default value .exponential with 5 retry and duration 2.0
153
+
/// - validate: Set of custom validate fun ``Http.Validate`` For status code like an example Default value to validate statusCode == 200 You can set diff combinations check out ``Http.Validate.Status``
145
154
/// - taskDelegate: A protocol that defines methods that URL session instances call on their delegates to handle task-level events
/// Send custom request based on the specific request instance
163
173
/// - Parameters:
164
174
/// - request: A URL load request that is independent of protocol or URL scheme
165
175
/// - retry: ``RetryService.Strategy`` strategy Default value .exponential with 5 retry and duration 2.0
176
+
/// - validate: Set of custom validate fun ``Http.Validate`` For status code like an example Default value to validate statusCode == 200 You can set up diff combinations check out ``Http.Validate.Status``
166
177
/// - taskDelegate: A protocol that defines methods that URL session instances call on their delegates to handle task-level events
0 commit comments