             return
         }
 
-        let task = URLSession.shared.dataTask(with: request) { (data, _, _) in
+        let configuration = URLSessionConfiguration.ephemeral
+        configuration.timeoutIntervalForRequest = 30
+
+        let session = URLSession(
+            configuration: configuration,
+            delegate: self,
+            delegateQueue: nil
+        )
+
+        let task = session.dataTask(with: request) { (data, _, _) in
             guard let data = data else { return }
             let json = try? JSON(data: data)
             completion?(APIResult<R>(raw: json))

import Foundation
import SwiftyJSON

class API {
    static let shared: API! = API(host: "https://open.rocket.chat")

    var host: URL

        task.resume()
    }
}

extension API: URLSessionTaskDelegate {

    func urlSession(_ session: URLSession, task: URLSessionTask, willPerformHTTPRedirection response: HTTPURLResponse, newRequest request: URLRequest, completionHandler: @escaping (URLRequest?) -> Void) {

    }

}
