docs/Protocols/RequestAdapter.html
public protocol RequestAdapter : Sendable
A type that can inspect and optionally adapt a URLRequest in some manner if necessary.
`
adapt(_:for:completion:)
`
Inspects and adapts the specified URLRequest in some manner and calls the completion handler with the Result.
Swift
func adapt(_ urlRequest: URLRequest, for session: Session, completion: @escaping @Sendable (_ result: Result<URLRequest, any Error>) -> Void)
| urlRequest |
The URLRequest to adapt.
|
| session |
The Session that will execute the URLRequest.
|
| completion |
The completion handler that must be called when adaptation is complete.
|
`
adapt(_:using:completion:)
` Default implementation
Inspects and adapts the specified URLRequest in some manner and calls the completion handler with the Result.
Swift
func adapt(_ urlRequest: URLRequest, using state: RequestAdapterState, completion: @escaping @Sendable (_ result: Result<URLRequest, any Error>) -> Void)
| urlRequest |
The URLRequest to adapt.
|
| state |
The RequestAdapterState associated with the URLRequest.
|
| completion |
The completion handler that must be called when adaptation is complete.
|
Self == Adapter`
adapter(using:)
` Extension method
Creates an Adapter using the provided AdaptHandler closure.
Swift
@preconcurrency
public static func adapter(using closure: @escaping AdaptHandler) -> Adapter
| closure |
AdaptHandler to use to adapt the request.
|
The Adapter.