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
+49-15Lines changed: 49 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -215,41 +215,75 @@ let configuration = NetworkConfiguration(
215
215
216
216
### Request Interceptors
217
217
218
-
Modify requests before they're sent using synchronous or asynchronous interceptors.
218
+
Modify requests before they are sent by creating a chain of objects that conform to the `NetworkRequestInterceptor` protocol. This is useful for cross-cutting concerns like adding authentication tokens, logging, or caching headers.
219
219
220
-
#### Synchronous Interceptor
220
+
#### 1. Create an Interceptor
221
221
222
-
A synchronous interceptor is useful for quick modifications, like adding a static header.
222
+
First, define a struct or class that conforms to `NetworkRequestInterceptor` and implement the `intercept` method.
223
223
224
224
```swift
225
-
let configuration =NetworkConfiguration(
226
-
baseURL: URL(string: "https://api.example.com")!,
227
-
interceptor: { request in
225
+
// An interceptor for adding a static API key to every request.
0 commit comments