Request Customization
-
The possible actions a chained request may take after the underlying request completes.
See moreDeclaration
Swift
public enum RequestChainAction
-
Allows you to create
Request
s 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 toResource.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, usingRequestDelegate
:- 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
andRequestChainDelgate
in Siesta’s source code for examples of implementing this protocol.See also
Resource.prepareRequest(using:)
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:)
Declaration
Swift
public protocol RequestCompletionHandler