Back to Alamofire

RequestAdapter

docs/docsets/Alamofire.docset/Contents/Resources/Documents/Protocols/RequestAdapter.html

5.12.02.3 KB
Original Source

RequestAdapter

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.

Declaration

Swift

func adapt(_ urlRequest: URLRequest, for session: Session, completion: @escaping @Sendable (_ result: Result<URLRequest, any Error>) -> Void)

Parameters

| 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.

Default Implementation

Declaration

Swift

func adapt(_ urlRequest: URLRequest, using state: RequestAdapterState, completion: @escaping @Sendable (_ result: Result<URLRequest, any Error>) -> Void)

Parameters

| urlRequest |

The URLRequest to adapt.

| | state |

The RequestAdapterState associated with the URLRequest.

| | completion |

The completion handler that must be called when adaptation is complete.

|

Available where Self == Adapter

`

                adapter(using:)
                ` Extension method 

Creates an Adapter using the provided AdaptHandler closure.

Declaration

Swift

@preconcurrency
public static func adapter(using closure: @escaping AdaptHandler) -> Adapter

Parameters

| closure |

AdaptHandler to use to adapt the request.

|

Return Value

The Adapter.