TNRequestMiddlewareProtocol

public protocol TNRequestMiddlewareProtocol

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.

  • Modifies body params before they are sent to server

    Declaration

    Swift

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

    Parameters

    params

    The body params that are constructed by TNRequest initializers.

    Return Value

    • the new modified params

  • Modifies data response before they are sent to callbacks

    Declaration

    Swift

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

    Parameters

    data

    The data

    Return Value

    • the new modified data

  • Modifies the headers of the response before they are sent to server

    Declaration

    Swift

    func modifyHeadersBeforeSend(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()