Protocol
Component
public protocol Component
A protocol
defining a unique identifier
for a specific request component.
The user can define custom components
to be used inside EndpointBuilder
.
Relationships
Types Conforming to Component
Cellular
A
struct
defining whether the request for a given endpoint can run on cellular or not. Defaults totrue
.Constrained
A
struct
defining whether the request for a given endpoint should run on a constrained network. Defaults totrue
.Expensive
A
struct
defining whether the request for a given endpoint is considered expensive. Defaults totrue
.Service
A
struct
defining the request network service type for a specific endpoint. /// Defaults to.default
.Timeout
A
struct
defining when the request for a given endpoint can timeout. Defaults to60
.Body
A
struct
defining the request body for a given endpoint. Defaults tonil
.Headers
A
struct
defining the request headers for a given endpoint. Defaults to empty.Method
A
struct
defining the request HTTP method for a given endpoint.Query
A
struct
defining the query items for a given endpoint. Defaults to empty.
Default Implementations
inherit(from:_:)
mutating func inherit(from original: any Component)
Inherit some previously cached value. Default implementation does nothing, meaning cached values are simply overridden.
Path("https://github.com")
PathComponent("sbertix")
PathComponent("ComposableRequest")
would be resolved to the repo path.
Headers("value1", forKey: "key1")
Headers("value2", forKey: "key2")
would be resolved to ["key1": "value1", "key2": "value2"]
.
Parameters
Name | Type | Description |
---|---|---|
original | any |
The original value for the cached component. |
Requirements
Value
associatedtype Value
The associated value type.
defaultValue
static var defaultValue: Self
The default value when no cached component can be found.
value
var value: Value
The value connected to the current component.
inherit(from:_:)
mutating func inherit(from original: any Component)
Inherit some previously cached value. Default implementation simply replaces the current value.
Path("https://github.com")
PathComponent("sbertix")
PathComponent("ComposableRequest")
would be resolved to the repo path.
Headers("value1", forKey: "key1")
Headers("value2", forKey: "key2")
would be resolved to ["key1": "value1", "key2": "value2"]
.
Parameters
Name | Type | Description |
---|---|---|
original | any |
The original value for the cached component. |
update(_:)
func update(_ request: inout URLRequest)
Update a given URLRequest
.
Parameters
Name | Type | Description |
---|---|---|
request | inout URLRequest |
A mutable |