RestingInterceptor

public protocol RestingInterceptor

Represents an object that is able to intercept requests and responses.

Sample implementation that does nothing:

class EmptyInterceptor: RestingInterceptor {
    func intercept(request: HTTPRequest, execution: Execution) -> ProgressablePromise<HTTPDataResponse> {
        return execution()
    }
}
  • Represents the interceptor execution chain.

    Declaration

    Swift

    typealias Execution = (HTTPRequest) -> ProgressablePromise<HTTPDataResponse>
  • Intercepts a sending request. The response to the request can be retrieved from the promise returned by execution.

    Warning

    The implementation must call execution if the request is to be sent. The implementation might decide to not send the request or modify the request sent by passing another request to execution.

    Declaration

    Swift

    func intercept(request: HTTPRequest, execution: @escaping Execution) -> ProgressablePromise<HTTPDataResponse>

    Parameters

    request

    The request that is being sent.

    execution

    The function that executes the request.

    Return Value

    A promise to the request’s response.