Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Kotlin native equivalent of Retrofit

With Kotlin native giving us the promise of cross platform development and native executables, is there an equivalent of the Java lib Retrofit for Kotlin Native? IOW is there a pure Kotlin networking library that makes creating http client code simple, and quick as Retrofit does for Java?

like image 473
Patrick Avatar asked Dec 13 '17 17:12

Patrick


2 Answers

I've just published an example project where I use ktor-client in a Kotlin project with both iOS and Android.

https://github.com/thoutbeckers/kotlin-mpp-example

( note: this example is now very out of date, but in the meanwhile ktor has progressed tremendously, and also have a multiplatform sample: https://ktor.io/learn/ )

like image 95
thoutbeckers Avatar answered Oct 15 '22 20:10

thoutbeckers


At the moment wrapping some C library, like CURL is the best option. See https://github.com/JetBrains/kotlinconf-spinner/tree/master/kurl for example of how it could be done.

In this example we provide interoperability library matching CURL directly, and more Kotlin'ish wrapper, which calls (somewhat confusing) CURL APIs in more easy to use manner.

like image 31
Nikolay Igotti Avatar answered Oct 15 '22 22:10

Nikolay Igotti