URLRequestConvertible
public protocol URLRequestConvertible
Represents a type which could be converted to a URLRequest
with specified components.
-
path
Default implementationURL path for the request as String. Returns an empty string as default.
Default Implementation
Declaration
Swift
var path: String { get }
-
method
Default implementationThe HTTP request method as an
HTTPMethod
String enumeration. Returnsget
case as default.Default Implementation
Declaration
Swift
var method: HTTPMethod { get }
-
parameters
Default implementationThe request parameters as
Parameters
. Returns nil as default.Default Implementation
Declaration
Swift
var parameters: Parameters? { get }
-
headers
Default implementationThe request HTTP header fields. Returns nil as default.
Default Implementation
Declaration
Swift
var headers: HTTPHeaders? { get }
-
multipartAttachments
Default implementationThe attachments for a multipart form data request
Default Implementation
Declaration
Swift
var multipartAttachments: MultipartAttachments? { get }
-
parameterEncoding
Default implementationDefault Implementation
Declaration
Swift
var parameterEncoding: ParameterEncoding { get }
-
asURLRequest(path:
Default implementationheaders: parameters: attachments: ) 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 theURLRequest
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
.