HTTPRequest

public protocol HTTPRequest

A protocol for defining a HTTP request.

  • Declaration

    Swift

    associatedtype ResponseObject
  • Declaration

    Swift

    associatedtype ErrorObject : Error
  • The base URL.

    Declaration

    Swift

    var baseURL: URL { get }
  • The URL path.

    Declaration

    Swift

    var path: String { get }
  • method Default implementation

    The HTTP method used in the request.

    Default Implementation

    Declaration

    Swift

    var method: HTTPMethod { get }
  • queryItems Default implementation

    An array of query items to be appended to the URL path.

    Default Implementation

    Declaration

    Swift

    var queryItems: [URLQueryItem]? { get }
  • headers Default implementation

    Dictionary of headers.

    Default Implementation

    Declaration

    Swift

    var headers: [String : String]? { get }
  • timeout Default implementation

    A TimeInterval of when the request should timeout.

    Default Implementation

    Declaration

    Swift

    var timeout: TimeInterval { get }
  • A Bool to indicate whether the request is authenticated or not.

    Declaration

    Swift

    var isAuthenticated: Bool { get }
  • HTTP body of the request.

    Declaration

    Swift

    var body: Data? { get set }
  • Processes the response.

    Declaration

    Swift

    func process(data: Data, response: URLResponse) throws -> ResponseObject

    Return Value

    The response object