URLRequest
extension URLRequest: URLRequestConvertible
-
Returns
self
.Declaration
Swift
public func asURLRequest() throws -> URLRequest
-
Creates a
URLRequest
instance with the specifiedurl
,method
, andheaders
.Declaration
Swift
public init(url: URLConvertible, method: HTTPMethod, headers: HTTPHeaders? = nil) throws
Parameters
url
A
URLConvertible
value.method
An
HTTPMethod
.headers
The
HTTPHeaders
,nil
by default. -
Creates a
URLRequest
instance with the specifiedurl
,method
,headers
,parameters
andmultipart attachments
.Declaration
Swift
public init(url: URLConvertible, method: HTTPMethod, headers: HTTPHeaders? = nil, parameters: Parameters?, multipartAttachments: MultipartAttachments? = nil, encoding: ParameterEncoding = .urlEncodedForm) throws
Parameters
url
A
URLConvertible
value.method
An
HTTPMethod
.headers
The
HTTPHeaders
,nil
by default.parameters
A
Parameters
valuemultipartAttachments
An array of
URL
s of the attachments.encoding
The parameter encoding type to use.
-
Encodes parameters and applies them to the
URLRequest
.Throws
AnError
if the encoding process encounters an error.Declaration
Swift
public mutating func encode(with parameters: Parameters?, encoding: ParameterEncoding = .urlEncodedForm) throws
Parameters
parameters
The
Parameters
to apply.encoding
The parameter encoding type to use.
-
Encodes parameters by applying them to an existing
URLRequest
.Throws
AnError
if the encoding process encounters an error.Declaration
Swift
public static func encode(_ urlRequest: inout URLRequest, with parameters: Parameters?, encoding: ParameterEncoding = .urlEncodedForm) throws
Parameters
urlRequest
The
URLRequest
to have parameters applied.parameters
The
Parameters
to apply.encoding
The parameter encoding type to use.