Created
July 27, 2019 08:33
-
-
Save Audhil/0f1f5efca4a6f605f8ecbf270ab60518 to your computer and use it in GitHub Desktop.
retrofit2 interface in Android - https://android.jlelse.eu/handmade-backend-for-android-app-using-python-flask-framework-b173ba2bb3aa
This file contains 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
class APIKindaStuff { | |
interface APIService { | |
@GET("/users/{user}") | |
fun greetUser(@Path("user") user: String): Call<ResponseBody> | |
@Headers("Content-type: application/json") | |
@POST("/api/post_some_data") | |
fun getVectors(@Body body: JsonObject): Call<ResponseBody> | |
} | |
companion object { | |
private val retrofit = Retrofit.Builder() | |
.baseUrl("http://XXX.XXX.X.X:5000") | |
.addConverterFactory(GsonConverterFactory.create(GsonBuilder().create())) | |
.build() | |
var service = retrofit.create(APIService::class.java) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment