ResponsePipelineRedirector
public protocol ResponsePipelineRedirector : AnyObject
Represents a redirection stage of a series of response pipelines. Use redirectors to additionally
perform data processing by invoking closure
with a proper
ResponsePipelineRedirectorAction
enumeration member.
-
Whether this redirector should be applied to execute and handle a received HTTP response.
Declaration
Swift
func shouldApply<T>(request: T, data: Data, response: HTTPURLResponse) -> Bool where T : Request
Parameters
request
The original
Request
.data
The received data contained in the HTTP response.
response
The received HTTP response to the request.
-
Performs the redirect action for current redirector. Define how to process the received response and data. When the process is finished, call
closure
with the required action to make the response pipeline continue.Declaration
Swift
func redirect<T: Request>( request: T, data: Data, response: HTTPURLResponse, done closure: @escaping (ResponsePipelineRedirectorAction) throws -> Void) throws
Parameters
request
The original
Request
.data
The received data contained in the HTTP response.
response
The received HTTP response to the request.
closure
A block to be called when you have finished processing the received response and data. The block takes a single parameter, which must be one of the member in the
ResponsePipelineRedirectorAction
enumeration.