InterceptingFloret

public protocol InterceptingFloret : Floret

An InterceptingFloret can process requests and responses.

  • If an InterceptingFloret is disabled both functions willRequest and didRespond will not be called anymore. A InterceptingFloret doesn’t need to perform any specific action.

    Declaration

    Swift

    var enabled: Bool { get set }
  • This function will be called before a request is performed. The InterceptingFlorets will be called in the order the Cauli instance got initialized with.

    Using this function you can:

    • inspect the request
    • modify the request (update the designatedRequest)
    • fail the request (set the result to .error())
    • return a cached or pre-calculated response (set the result to .result())

    Declaration

    Swift

    func willRequest(_ record: Record, modificationCompletionHandler completionHandler: @escaping (Record) -> Void)

    Parameters

    record

    The Record that represents the request before it was performed.

    completionHandler

    Call this completion handler exactly once with the original or modified Record.

  • This function will be called after a request is performed and the response arrived. The InterceptingFlorets will be called in the order the Cauli instance got initialized with.

    Using this function you can:

    • modify the request

    Declaration

    Swift

    func didRespond(_ record: Record, modificationCompletionHandler completionHandler: @escaping (Record) -> Void)

    Parameters

    record

    The Record that represents the request after it was performed.

    completionHandler

    Call this completion handler exactly once with the original or modified Record.