RestingHeaderProvider
public class RestingHeaderProvider : HeaderProvider
A default implementation of HeaderProvider supporting dynamic header provisioning.
-
The headers to add to a request on a given time. Generated from
providers, discartingnilvalues.Declaration
Swift
public var headers: [String : String] { get } -
Creates a new
RestingHeaderProviderwith the given header callbacks.Declaration
Swift
public init(providers: [String : () -> (String?)] = [:])Parameters
providersThe callbacks to generate headers for requests. Keys indicate the name and the return of the callback the value of the header to add.
nilvalues are discarted. -
Adds a static header value for the given key.
Adding a header to an existing overrides the previous one.
Declaration
Swift
public func addHeader(key: String, value: String)Parameters
keyThe name of the header.
valueThe value of the header.
-
Adds a dynamic header value for the given key.
Adding a header to an existing overrides the previous one.
Declaration
Swift
public func addHeader(key: String, provider: @escaping () -> String?)Parameters
keyThe name of the header.
providerThe provider to call for the header value.
nilvalues are discarted. -
Removes a header added for the given key.
Declaration
Swift
public func removeHeader(for key: String)Parameters
keyThe name of the header to remove.
RestingHeaderProvider Class Reference