-
Notifications
You must be signed in to change notification settings - Fork 26
Description
As for #283 the different requests method provide headers
as an optionnal parameter.
Nonetheless, if we go up in the stack of calls, no headers are passed to these methods. We should be able to pass them.
For example here:
meilisearch-swift/Sources/MeiliSearch/Documents.swift
Lines 16 to 23 in 431d8ee
func get<T>( | |
_ uid: String, | |
_ identifier: String, | |
_ completion: @escaping (Result<T, Swift.Error>) -> Void) | |
where T: Codable, T: Equatable { | |
let query: String = "/indexes/\(uid)/documents/\(identifier)" | |
self.request.get(api: query) { result in | |
switch result { |
the request.get
does not provide the headers that can be passed as an argument here
meilisearch-swift/Sources/MeiliSearch/Request.swift
Lines 31 to 35 in 431d8ee
func get( | |
api: String, | |
param: String? = nil, | |
headers: [String: String] = [:], | |
_ completion: @escaping (Result<Data?, Swift.Error>) -> Void) { |
We should be able to provide the information.
Two possible solutions this.config
can contain the specific headers. In which case we can remove the headers
params from the request methods.
Or we provide them as an optional parameter for each method:
public func createIndex(
uid: String,
primaryKey: String? = nil,
headers: [String: String] = [:],
_ completion: @escaping (Result<Task, Swift.Error>) -> Void) {
Indexes.create(uid: uid, primaryKey: primaryKey, config: self.config, completion)
}
I prefer the first option but this also means an additional parameter during the initialisation of a Meilisearch client.
public init(
host: String,
apiKey: String? = nil,
session: URLSessionProtocol? = nil,
request: Request? = nil,
headers: [String: String] = [:]) throws {