Storage Documentation

Structure Body

public struct Body: Component  

A struct defining the request body for a given endpoint. Defaults to nil.

%77 Body Body Component Component Body->Component

Conforms To

Component

A protocol defining a unique identifier for a specific request component.

Initializers

init(_:​)

public init(_ body: Data?)  

Init.

Parameters

body Data?

The request body for a given endpoint.

init(_:​encoder:​)

public init(_ body: some Encodable, encoder: JSONEncoder = .init())  

Init.

Parameters

body some Encodable

Some Encodable instance.

encoder JSONEncoder

A valid JSONEncoder. Defaults to .init.

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

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

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

body some Encodable

Some Encodable.

encoder E

Some TopLevelEncoder.

Properties

default​Value

public static var defaultValue: Body  

The default value when no cached component can be found.

value

public let value: Data? 

The request body for a given endpoint.

Methods

update(_:​)

public func update(_ request: inout URLRequest)  

Update a given URLRequest.

Parameters

request inout URLRequest

A mutable URLRequest.