RequestAdapter

public protocol RequestAdapter : Sendable

A type that can inspect and optionally adapt a URLRequest in some manner if necessary.

  • 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