Building REST Clients with Retrofit 2
On Android and JVM, Retrofit 2 became my go-to HTTP client.
Setup was easy:
1
2
3
4
5
Retrofit retrofit = new Retrofit.Builder()
.baseUrl("https://api.example.com/")
.addConverterFactory(GsonConverterFactory.create())
.build();
I especially liked:
- Interface-based declarative APIs
- Easy mocking with interceptors
- Integration with RxJava
A must-have when working with external APIs.
This post is licensed under CC BY 4.0 by the author.