@@ -74,7 +74,8 @@ public class Client {
7474 /// :param: apiKey a valid API key for the service
7575 /// :param: tagFilters value of the header X-Algolia-TagFilters
7676 /// :param: userToken value of the header X-Algolia-UserToken
77- public init ( appID: String , apiKey: String , tagFilters: String ? = nil , userToken: String ? = nil ) {
77+ /// :param: hostnames the list of hosts that you have received for the service
78+ public init ( appID: String , apiKey: String , tagFilters: String ? = nil , userToken: String ? = nil , hostnames: [ String ] ? = nil ) {
7879 if count ( appID) == 0 {
7980 NSException ( name: " InvalidArgument " , reason: " Application ID must be set " , userInfo: nil ) . raise ( )
8081 } else if count ( apiKey) == 0 {
@@ -86,20 +87,25 @@ public class Client {
8687 self . tagFilters = tagFilters
8788 self . userToken = userToken
8889
89- readQueryHostnames = [
90- " \( appID) -DSN.algolia.net " ,
91- " \( appID) -1.algolianet.com " ,
92- " \( appID) -2.algolianet.com " ,
93- " \( appID) -3.algolianet.com "
94- ]
95-
96- writeQueryHostnames = [
97- " \( appID) .algolia.net " ,
98- " \( appID) -1.algolianet.com " ,
99- " \( appID) -2.algolianet.com " ,
100- " \( appID) -3.algolianet.com "
101- ]
102-
90+ if let hostnames = hostnames {
91+ readQueryHostnames = hostnames
92+ writeQueryHostnames = hostnames
93+ } else {
94+ readQueryHostnames = [
95+ " \( appID) -DSN.algolia.net " ,
96+ " \( appID) -1.algolianet.com " ,
97+ " \( appID) -2.algolianet.com " ,
98+ " \( appID) -3.algolianet.com "
99+ ]
100+
101+ writeQueryHostnames = [
102+ " \( appID) .algolia.net " ,
103+ " \( appID) -1.algolianet.com " ,
104+ " \( appID) -2.algolianet.com " ,
105+ " \( appID) -3.algolianet.com "
106+ ]
107+ }
108+
103109 let version = NSBundle ( forClass: self . dynamicType) . infoDictionary![ " CFBundleShortVersionString " ] as! String
104110
105111 var HTTPHeaders = [
@@ -179,7 +185,7 @@ public class Client {
179185
180186 /// Return 10 last log entries.
181187 public func getLogs( block: CompletionHandler ) {
182- performHTTPQuery ( " 1/logs " , method: . GET, body: nil , hostnames: readQueryHostnames , block: block)
188+ performHTTPQuery ( " 1/logs " , method: . GET, body: nil , hostnames: writeQueryHostnames , block: block)
183189 }
184190
185191 /// Return last logs entries.
0 commit comments