Hyun
01/02/2021, 1:56 PMRetrofit-style
KMP Network library using Ktor
It provides the below
- Support Retrofit Annotation : it means that you can use Retrofit interface
- Similar function to CallAdapter of Retrofit(Okhttp interceptor is supported by Ktor)
for simple migration from Retrofit to this library.
just change Retrofit object to HttpClient of Ktor like the below
Using Retrofit
inline <reified T> fun getApi(baseUrl: String): T {
return getRetrofit(baseUrl).create(T::class.java)
}
This Library
inline <reified T> fun getApi(baseUrl: String): T {
return getHttpClinet().create(baseUrl)
}
I think this library helps to migrate android+retrofit project to KMP easily.
further detail here