Structure
Body
public struct Body: Component
A struct defining the request body for a given endpoint.
Defaults to nil.
Relationships
Conforms To
ComponentA
protocoldefining a unique identifier for a specific request component.
Initializers
init(_:)
public init(_ body: Data?)
Init.
Parameters
| Name | Type | Description |
|---|---|---|
| body | Data? |
The request body for a given endpoint. |
init(_:encoder:)
public init(_ body: some Encodable, encoder: JSONEncoder = .init())
Init.
Parameters
| Name | Type | Description |
|---|---|---|
| body | some Encodable |
Some |
| encoder | JSONEncoder |
A valid |
init(parameters:)
public init(parameters body: [String: String])
Init.
A dictionary like ["key1": "value1", "key2": "value2"]
converts into the data representation of a String like
key1=value1&key2=value2.
Parameters
| Name | Type | Description |
|---|---|---|
| body | [String: String] |
The request body parameters for a given endpoint. |
init(parameters:)
public init(parameters body: [String: String?])
Init.
A dictionary like ["key1": "value1", "key2": "value2"]
converts into the data representation of a String like
key1=value1&key2=value2.
Parameters
| Name | Type | Description |
|---|---|---|
| body | [String: String?] |
The request body parameters for a given endpoint. |
init(_:encoder:)
public init<E: TopLevelEncoder>(_ body: some Encodable, encoder: E) where E.Output == Data
Init.
Parameters
| Name | Type | Description |
|---|---|---|
| body | some Encodable |
Some |
| encoder | E |
Some |
Properties
defaultValue
public static var defaultValue: Body
The default value when no cached component can be found.
Methods
update(_:)
public func update(_ request: inout URLRequest)
Update a given URLRequest.
Parameters
| Name | Type | Description |
|---|---|---|
| request | inout URLRequest |
A mutable |