Requestable

Represents an HTTP Request that can be asynchronously executed. You must provide a path.

Creating a request.

import Restofire
import Alamofire

struct PersonPOSTService: Requestable {

let path: String let method: Alamofire.HTTPMethod = .post let parameters: Any?

init(id: String, parameters: Any? = nil) { self.path = person/se>\(n>idse>)s> self.parameters = parameters }

}

Consuming the request.

import Restofire
import Alamofire

class ViewController: UIViewController {

var request: PersonPOSTService! var person: Any!

func createPerson() { request = PersonPOSTService(id: 123456789, parameters: person).executeTask() }

deinit { request.cancel() }

}

  • baseURL Default implementation

    The base URL.

    Default Implementation

    configuration.BaseURL

    Declaration

    Swift

    var baseURL: String
  • The response type.

    Declaration

    Swift

    associatedtype Model
  • The path relative to base URL.

    Declaration

    Swift

    var path: String
  • method Default implementation

    The HTTP Method.

    Default Implementation

    configuration.method

    Declaration

    Swift

    var method: Alamofire.HTTPMethod
  • encoding Default implementation

    The request parameter encoding.

    Default Implementation

    configuration.encoding

    Declaration

    Swift

    var encoding: Alamofire.ParameterEncoding
  • headers Default implementation

    The HTTP headers.

    Default Implementation

    nil

    Declaration

    Swift

    var headers: [String : String]?
  • parameters Default implementation

    The request parameters.

    Default Implementation

    nil

    Declaration

    Swift

    var parameters: Any?
  • logging Default implementation

    The logging.

    Default Implementation

    configuration.logging

    Declaration

    Swift

    var logging: Bool
  • sessionManager Default implementation

    The Alamofire Session Manager.

    Default Implementation

    configuration.sessionManager

    Declaration

    Swift

    var sessionManager: Alamofire.SessionManager
  • queue Default implementation

    The queue on which reponse will be delivered.

    Default Implementation

    configuration.queue

    Declaration

    Swift

    var queue: DispatchQueue?
  • credential Default implementation

    The credential.

    Default Implementation

    authentication.credential

    Declaration

    Swift

    var credential: URLCredential?
  • validationBlock Default implementation

    The Alamofire validation.

    Default Implementation

    validation.validation

    Declaration

    Swift

    var validationBlock: Alamofire.DataRequest.Validation?
  • acceptableStatusCodes Default implementation

    The acceptable status codes.

    Default Implementation

    validation.acceptableStatusCodes

    Declaration

    Swift

    var acceptableStatusCodes: [Int]?
  • acceptableContentTypes Default implementation

    The acceptable content types.

    Default Implementation

    validation.acceptableContentTypes

    Declaration

    Swift

    var acceptableContentTypes: [String]?
  • retryErrorCodes Default implementation

    The retry error codes.

    Default Implementation

    retry.retryErrorCodes

    Declaration

    Swift

    var retryErrorCodes: Set<URLError.Code>
  • retryInterval Default implementation

    The retry interval.

    Default Implementation

    retry.retryInterval

    Declaration

    Swift

    var retryInterval: TimeInterval
  • maxRetryAttempts Default implementation

    The max retry attempts.

    Default Implementation

    retry.maxRetryAttempts

    Declaration

    Swift

    var maxRetryAttempts: Int
  • didStartRequest() Default implementation

    Called when the Request starts.

    Default Implementation

    Does nothing.

    Declaration

    Swift

    func didStartRequest()
  • Called when the Request succeeds.

    Default Implementation

    Does nothing.

    Declaration

    Swift

    func didCompleteRequestWithDataResponse(_ dataResponse: Alamofire.DataResponse<Self.Model>)

    Parameters

    response

    The Alamofire Response