Interceptor

public protocol Interceptor

Modifies URLRequests going out and the corresponding URLResponse coming back in. Usage e.g. for manipulating header field of an existing request.

  • Intercept the chain (e.g. modify it’s request)

    Note

    A call to chain.proceed(request:) is critical when implementing this protocol function.

    Declaration

    Swift

    func intercept(chain: Chain) -> AnyPublisher<HTTPResponse, HTTPClientError>

    Parameters

    chain

    request chain to be intercepted

    Return Value

    AnyPublisher that emits the response as HTTPClient.Response