Based on Java Dynamic Proxy
Written in educational purposes only
Using Denom common library for networking
Init HttpClient
val httpClient = HttpClient.Builder()
.baseUrl("https://cataas.com")
.build()
Create service interface
interface CatService {
@Get("cat")
fun getCatById(@Param("id") id: Long): HttpClientResponse
@Get("api/cats")
fun getCuteCats(@Param("tags") tags: String, @Param("limit") limit: Int): HttpClientResponse
}
Prepare service interface to use
val catService: CatService = httpClient.create()