Request Customization

  • Allows you to create Requests with custom logic. This is useful for taking things that are not standard network requests, and wrapping them so they look to Siesta as if they are. To create a custom request, pass your delegate to Resource.prepareRequest(using:).

    You can also implement Siesta’s Request protocol yourself, but this is a daunting task full of pitfalls and redundant effort. This protocol provides customization points for only the things custom requests typically need to customize, and provides standard behavior and sanity checks. In particular, using RequestDelegate:

    • provides standard implementations for all the request hooks,
    • ensures those hooks are called exactly once, even if your delegate misbehaves and reports multiple responses,
    • tracks request state and ensures valid state transitions,
    • polls request progress, and
    • handles cancellation cleanly, preventing “response after cancel” race conditions.

    Siesta itself uses this protocol to implement its own requests. Look at NetworkRequestDelegate and RequestChainDelgate in Siesta’s source code for examples of implementing this protocol.

    See more

    Declaration

    Swift

    public protocol RequestDelegate
  • Provides callbacks for a RequestDelegate to use once its underlying operation is complete and it has response data to report.

    See also

    RequestDelegate.startUnderlyingOperation(completionHandler:)
    See more

    Declaration

    Swift

    public protocol RequestCompletionHandler