RequestMiddlewareProtocol

public protocol RequestMiddlewareProtocol

This protocol is used to register a middleware in order to modify body and headers of a request. (e.g. it can be used with Crypto Swift library to encrypt or decrypt the data.

  • Processes body params before they are sent to server.

    Declaration

    Swift

    func processParams(with params: [String : Any?]?) throws -> [String : Any?]?

    Parameters

    params

    The body params that are constructed by Request initializers.

    Return Value

    The new modified params.

  • Processes response data after they have been received.

    Declaration

    Swift

    func processResponse(with data: Data?) throws -> Data?

    Parameters

    data

    The response data.

    Return Value

    The new modified data

  • Processes the response headers before they are sent to server.

    Declaration

    Swift

    func processHeadersBeforeSend(with headers: [String : String]?) throws -> [String : String]?

    Parameters

    headers

    the headers cosntructed by initializers and configuration

    Return Value

    The new modified headers.

  • Processes response headers after they have been received.

    Declaration

    Swift

    func processHeadersAfterReceive(with headers: [String : String]?) throws -> [String : String]?

    Parameters

    headers

    the headers cosntructed by initializers and configuration.

    Return Value

    The new modified headers.

  • Required initializer

    Declaration

    Swift

    init()