docs/Protocols/ParameterEncoder.html
public protocol ParameterEncoder : Sendable
A type that can encode any Encodable type into a URLRequest.
`
encode(_:into:)
`
Encode the provided Encodable parameters into request.
Throws
An Error when encoding fails. For Alamofire provided encoders, this will be an instance of AFError.parameterEncoderFailed with an associated ParameterEncoderFailureReason.
Swift
func encode<Parameters>(_ parameters: Parameters?, into request: URLRequest) throws -> URLRequest where Parameters : Encodable, Parameters : Sendable
| parameters |
The Encodable parameter value.
|
| request |
The URLRequest into which to encode the parameters.
|
A URLRequest with the result of the encoding.
Self == JSONParameterEncoder`
json
` Extension method
Provides a default JSONParameterEncoder instance.
Swift
public static var json: JSONParameterEncoder { get }
`
json(encoder:)
` Extension method
Creates a JSONParameterEncoder using the provided JSONEncoder.
Swift
public static func json(encoder: JSONEncoder = JSONEncoder()) -> JSONParameterEncoder
| encoder |
JSONEncoder used to encode parameters. JSONEncoder() by default.
|
The JSONParameterEncoder.
Self == URLEncodedFormParameterEncoder`
urlEncodedForm
` Extension method
Provides a default URLEncodedFormParameterEncoder instance.
Swift
public static var urlEncodedForm: URLEncodedFormParameterEncoder { get }
`
urlEncodedForm(encoder:destination:)
` Extension method
Creates a URLEncodedFormParameterEncoder with the provided encoder and destination.
Swift
public static func urlEncodedForm(encoder: URLEncodedFormEncoder = URLEncodedFormEncoder(),
destination: URLEncodedFormParameterEncoder.Destination = .methodDependent) -> URLEncodedFormParameterEncoder
| encoder |
URLEncodedFormEncoder used to encode the parameters. URLEncodedFormEncoder() by default.
|
| destination |
Destination to which to encode the parameters. .methodDependent by default.
|
The URLEncodedFormParameterEncoder.