URLRequestConvertible

public protocol URLRequestConvertible

Represents a type which could be converted to a URLRequest with specified components.

  • path Default implementation

    URL path for the request as String. Returns an empty string as default.

    Default Implementation

    Declaration

    Swift

    var path: String { get }
  • method Default implementation

    The HTTP request method as an HTTPMethod String enumeration. Returns get case as default.

    Default Implementation

    Declaration

    Swift

    var method: HTTPMethod { get }
  • parameters Default implementation

    The request parameters as Parameters. Returns nil as default.

    Default Implementation

    Declaration

    Swift

    var parameters: Parameters? { get }
  • headers Default implementation

    The request HTTP header fields. Returns nil as default.

    Default Implementation

    Declaration

    Swift

    var headers: HTTPHeaders? { get }
  • multipartAttachments Default implementation

    The attachments for a multipart form data request

    Default Implementation

    Declaration

    Swift

    var multipartAttachments: URLRequest.MultipartAttachments? { get }
  • Returns a URLRequest or throws if an error was encountered.

    Additional header fields, parameters and/or multipart attachments can be passed to the method to be added on converting to a URLRequest object.

    Throws

    Error thrown when the convertion fails.

    Note

    The default implementation creates the URLRequest using the component properties.

    Default Implementation

    Declaration

    Swift

    func asURLRequest(headers additionalHeaders: HTTPHeaders,
                      parameters additionalParameters: Parameters,
                      attachments additionalAttachements: URLRequest.MultipartAttachments) throws -> URLRequest

    Parameters

    additionalHeaders

    Additional HTTP headers to add upon converting to a URLRequest object.

    additionalParameters

    Addtional parameters to add upon converting to a URLRequest object.

    additionalAttachments

    Addtional multipart attachements to add upon converting to a URLRequest object.

    Return Value

    The URLRequest.