This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// MARK: - Main Target | |
final class HTTPClient { | |
private let session: URLSession | |
init(session: URLSession = URLSession.shared) { | |
self.session = session | |
} | |
func get(from url: URL) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// MARK: - Main Target | |
protocol HTTPSession { | |
func dataTask(with url: URL, completionHandler: @escaping (Data?, URLResponse?, Error?) -> Void) -> HTTPSessionTask | |
} | |
protocol HTTPSessionTask { | |
func resume() | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// MARK: - Main Target | |
final class HTTPClient { | |
let session: URLSession | |
init(session: URLSession = URLSession.shared) { | |
self.session = session | |
} | |
func get(from url: URL) { | |
session.dataTask(with: URLRequest(url: url)).resume() |