Requests Documentation

Structure Query

public struct Query: Component  

A struct defining the query items for a given endpoint. Defaults to empty.

%103 Query Query Component Component Query->Component

Conforms To

Component

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

Initializers

init(_:​)

public init<C: Sequence>(_ items: C) where C.Element == URLQueryItem  

Init.

Parameters

items C

The query items for a given endpoint.

init(with​Flags:​)

public init(withFlags query: [String: String?])  

Init.

Parameters

query [String:​ String?]

The query items for a given endpoint.

init(_:​)

public init(_ query: [String: String?])  

Init.

Parameters

query [String:​ String?]

The query items for a given endpoint.

init(_:​)

public init(_ query: [String: String])  

Init.

Parameters

query [String:​ String]

The query items for a given endpoint.

init(_:​for​Key:​)

public init(_ value: String, forKey key: String)  

Init.

Parameters

value String

A String representing a single query item value.

key String

A String representing a single query item key.

init(_:​for​Key:​)

public init(_ value: String?, forKey key: String)  

Init.

Parameters

value String?

An optional String representing a single query item value. nil will be ignored.

key String

A String representing a single query item key.

Properties

default​Value

public static var defaultValue: Query  

The default value when no cached component can be found.

value

public var value: [URLQueryItem] 

The query items for a given endpoint.

Methods

inherit(from:​_:​)

public mutating func inherit(from original: any Component)  

Inherit some previously cached value.

Query("value1", forKey: "key1")
Query("value2", forKey: "key2")

would be resolved to ["key1": "value1", "key2": "value2"].

Parameters

original any

The original value for the cached component.

update(_:​)

public func update(_ request: inout URLRequest)  

Update a given URLRequest.

Parameters

request inout URLRequest

A mutable URLRequest.