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: MultipartAttachments? { get }
  • parameterEncoding Default implementation

    Default Implementation

    Declaration

    Swift

    var parameterEncoding: ParameterEncoding { 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(path updatePath: String?,
                      headers additionalHeaders: HTTPHeaders,
                      parameters additionalParameters: Parameters,
                      attachments additionalAttachments: MultipartAttachments) throws -> URLRequest

    Parameters

    path

    An optional string used to override the url path upon converting to a URLRequest object.

    headers

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

    parameters

    Addtional parameters to add upon converting to a URLRequest object.

    attachments

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

    Return Value

    The URLRequest.