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
executionif the request is to be sent. The implementation might decide to not send the request or modify the request sent by passing another request toexecution.Declaration
Swift
func intercept(request: HTTPRequest, execution: @escaping Execution) -> ProgressablePromise<HTTPDataResponse>Parameters
requestThe request that is being sent.
executionThe function that executes the request.
Return Value
A promise to the request’s response.
RestingInterceptor Protocol Reference