Skip to content

Instantly share code, notes, and snippets.

@BurningDroid
Created March 19, 2019 02:45
Show Gist options
  • Save BurningDroid/bba09aa21077e20d99c5a3428aaaaefc to your computer and use it in GitHub Desktop.
Save BurningDroid/bba09aa21077e20d99c5a3428aaaaefc to your computer and use it in GitHub Desktop.
Retrofit - How to set Interceptor
var client: OkHttpClient = OkHttpClient.Builder().apply {
connectTimeout(60, TimeUnit.SECONDS)
readTimeout(60, TimeUnit.SECONDS)
writeTimeout(60, TimeUnit.SECONDS)
addInterceptor(HttpLoggingInterceptor().apply {
level = HttpLoggingInterceptor.Level.BODY
})
}.build()
Retrofit.Builder builder = new Retrofit.Builder()
.baseUrl("http://localhost:3000/")
.client(okHttpClient)
.addConverterFactory(GsonConverterFactory.create())
.addCallAdapterFactory(RxJava2CallAdapterFactory.create());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment