Requestable

public protocol Requestable : BaseRequestable

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

  • Creates a RequestOperation for the specified Requestable object.

    Declaration

    Swift

    @discardableResult
    public func operation(
        parameters: Any? = nil,
        downloadProgressHandler: ((Progress) -> Void, queue: DispatchQueue?)? = nil,
        completionQueue: DispatchQueue = .main,
        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 enqueue(
        parameters: Any? = nil,
        downloadProgressHandler: ((Progress) -> Void, queue: DispatchQueue?)? = nil,
        completionQueue: DispatchQueue = .main,
        completionHandler: ((DataResponse<Response>) -> Void)? = nil
    ) throws -> Cancellable

    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 Cancellable.

  • Creates a RequestOperation for the specified Requestable object.

    Declaration

    Swift

    @discardableResult
    public func operation<T: Encodable>(
        parameters: T,
        downloadProgressHandler: ((Progress) -> Void, queue: DispatchQueue?)? = nil,
        completionQueue: DispatchQueue = .main,
        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 enqueue<T: Encodable>(
        parameters: T,
        downloadProgressHandler: ((Progress) -> Void, queue: DispatchQueue?)? = nil,
        completionQueue: DispatchQueue = .main,
        completionHandler: ((DataResponse<Response>) -> Void)? = nil
    ) throws -> Cancellable

    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 Cancellable.