Interceptor

public protocol Interceptor

Base Protocol for Interceptor. Interceptors are able to intercept a request and a response..

  • intercept(_:) Default implementation

    # Summary Intercepting the request to create the ability to modify the URLRequest before executing it. Example usages are adding request headers, authentication and request logging.

    Default Implementation

    Declaration

    Swift

    func intercept(_ request: URLRequest) -> URLRequest

    Parameters

    request

    The request to be intercepted.

    Return Value

    The intercepted and modified request.

  • intercept(response:data:error:) Default implementation

    # Summary Intercepting the response to add the ability to modify a response of a request. Additionally it is possible handle data and errors.

    Default Implementation

    Declaration

    Swift

    func intercept(response: URLResponse?, data: Data?, error: Error?) -> URLResponse?

    Parameters

    response

    The response returned by the data task

    data

    The data returned by the data task.

    error

    The error returned by the data task.

    Return Value

    The intercepted and modified response.