File tree Expand file tree Collapse file tree 1 file changed +25
-3
lines changed Expand file tree Collapse file tree 1 file changed +25
-3
lines changed Original file line number Diff line number Diff line change @@ -249,6 +249,26 @@ open class Client {
249249 ) ?? " "
250250 }
251251
252+ ///
253+ /// Sends a "ping" request to Appwrite to verify connectivity.
254+ ///
255+ /// @return String
256+ /// @throws Exception
257+ ///
258+ open func ping( ) async throws -> String {
259+ let apiPath : String = " /ping "
260+
261+ let apiHeaders : [ String : String ] = [
262+ " content-type " : " application/json "
263+ ]
264+
265+ return try await call (
266+ method: " GET " ,
267+ path: apiPath,
268+ headers: apiHeaders
269+ )
270+ }
271+
252272 ///
253273 /// Make an API call
254274 ///
@@ -319,6 +339,8 @@ open class Client {
319339 }
320340 }
321341
342+ var data = try await response. body. collect ( upTo: Int . max)
343+
322344 switch response. status. code {
323345 case 0 ..< 400 :
324346 if response. headers [ " Set-Cookie " ] . count > 0 {
@@ -331,10 +353,11 @@ open class Client {
331353 switch T . self {
332354 case is Bool . Type :
333355 return true as! T
356+ case is String . Type :
357+ return ( data. readString ( length: data. readableBytes) ?? " " ) as! T
334358 case is ByteBuffer . Type :
335- return try await response . body . collect ( upTo : Int . max ) as! T
359+ return data as! T
336360 default :
337- let data = try await response. body. collect ( upTo: Int . max)
338361 if data. readableBytes == 0 {
339362 return true as! T
340363 }
@@ -344,7 +367,6 @@ open class Client {
344367 }
345368 default :
346369 var message = " "
347- var data = try await response. body. collect ( upTo: Int . max)
348370 var type = " "
349371
350372 do {
You can’t perform that action at this time.
0 commit comments