Requestable

public protocol Requestable : _Requestable

Represents a Requestable for Restofire.

Create custom Requestable

protocol HTTPBinGETService: Requestable {

    typealias Response = Data
    var path: String? = "get"

}
  • validationBlock Default implementation

    The Alamofire data request validation.

    Default Implementation

    Validation.default.dataValidation

    Declaration

    Swift

    var validationBlock: DataRequest.Validation? { get }
  • request(_:didCompleteWithValue:) Default implementation

    Called when the Request succeeds.

    Default Implementation

    Does Nothing

    Declaration

    Swift

    func request(_ request: RequestOperation<Self>, didCompleteWithValue value: Response)

    Parameters

    request

    The Alamofire.DataRequest

    error

    The Response

  • request(_:didFailWithError:) Default implementation

    Called when the Request fails.

    Default Implementation

    Does Nothing

    Declaration

    Swift

    func request(_ request: RequestOperation<Self>, didFailWithError error: Error)

    Parameters

    request

    The Alamofire.DataRequest

    error

    The Error

  • asRequest() Extension method

    Creates a DataRequest to retrieve the contents of a URL based on the specified Requestable

    Declaration

    Swift

    func asRequest() throws -> DataRequest

    Return Value

    The created DataRequest.

  • Creates a RequestOperation for the specified Requestable object.

    Declaration

    Swift

    @discardableResult
    public func operation(
        downloadProgressHandler: ((Progress) -> Void)? = nil,
        completionHandler: ((DataResponse<Response>) -> Void)? = nil
    ) throws -> RequestOperation<Self>

    Parameters

    downloadProgressHandler

    A closure to be executed once the download progresses. nil by default.

    completionHandler

    A closure to be executed once the request has finished. nil by default.

    Return Value

    The created RequestOperation.

  • Creates a RequestOperation for the specified Requestable object.

    Declaration

    Swift

    public func operation(
        request: @autoclosure @escaping () -> DataRequest,
        downloadProgressHandler: ((Progress) -> Void)? = nil,
        completionHandler: ((DataResponse<Response>) -> Void)? = nil
    ) -> RequestOperation<Self>

    Parameters

    request

    A data request instance

    downloadProgressHandler

    A closure to be executed once the download progresses. nil by default.

    completionHandler

    A closure to be executed once the request has finished. nil by default.

    Return Value

    The created RequestOperation.

  • Creates a RequestOperation for the specified Requestable object and asynchronously executes it.

    Declaration

    Swift

    @discardableResult
    public func execute(
        downloadProgressHandler: ((Progress) -> Void)? = nil,
        completionHandler: ((DataResponse<Response>) -> Void)? = nil
    ) throws -> RequestOperation<Self>

    Parameters

    downloadProgressHandler

    A closure to be executed once the download progresses. nil by default.

    completionHandler

    A closure to be executed once the request has finished. nil by default.

    Return Value

    The created RequestOperation.

  • Creates a RequestOperation for the specified Requestable object and asynchronously executes it.

    Declaration

    Swift

    @discardableResult
    public func execute(
        request: @autoclosure @escaping () -> DataRequest,
        downloadProgressHandler: ((Progress) -> Void)? = nil,
        completionHandler: ((DataResponse<Response>) -> Void)? = nil
    ) -> RequestOperation<Self>

    Parameters

    request

    A data request instance

    downloadProgressHandler

    A closure to be executed once the download progresses. nil by default.

    completionHandler

    A closure to be executed once the request has finished. nil by default.

    Return Value

    The created RequestOperation.