Created
March 19, 2019 02:45
-
-
Save BurningDroid/bba09aa21077e20d99c5a3428aaaaefc to your computer and use it in GitHub Desktop.
Retrofit - How to set Interceptor
This file contains hidden or 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
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