์ ๐ญ Jerry ์ ๐ก Network๋ฅผ ํฉ์ณ์ ๐ Jetwork ํ์!
ํ๋ก์ ํธ๋ง๋ค NetworkManager๋ฅผ ๊ณ์ ๋ง๋๋๊ฒ ์ง์ณ์ ํจํค์ง๋ก ๋ง๋ค์์ต๋๋ค ๐
-
Async Await๊ณผ Completion Handler ๋ ๊ฐ์ง ๋ฐฉ์์ผ๋ก request๋ฅผ ํธ์ถํ ์ ์์ด์ ๐
-
Enum๋ด Request๋ฅผ ์ ์ํ์ฌ ํด๋น Request๊ฐ ์ํ API๋ฅผ ๋ช ํํ๊ฒ ์ ์ ์์ด์ ๐
-
Request๋ด Url, Request๋ฅผ ๊ตฌ์ฑํ๋ ๊ฐ์ฒด๊ฐ ๋ถ๋ฆฌ๋์ด ์์ด parameters, query, headers ๋ฑ ํ๋กํผํฐ๊ฐ ํผ๋๋์ง ์์์ ๐
-
Test Code ์์ฑ ๐
enum MockAPI { }
extension MockAPI {
struct MockRequest: Request {
typealias Parameter = EmptyParameter
typealias Response = MockResponse
var urlInfo: URLInfo = .MockAPI(path: "/test")
var requestInfo: Jetwork.NetworkAPI.RequestInfo<Jetwork.EmptyParameter> = .init(method: .get)
}
}
extension NetworkAPI.URLInfo {
/// MockAPI host ์ง์
static func MockAPI(path: String) -> Self {
return .init(host: "test.api.com", path: path)
}
}
- Rx๋ฅผ ์ด์ฉํ์ฌ request ํธ์ถ
- uploadTask, downLoadTask ์ง์
- Interceptor๋ฅผ ์ด์ฉํ์ฌ retry ๋ก์ง ๊ตฌํ
- Error ์ธ๋ถํ