Skip to content

Instantly share code, notes, and snippets.

@Lavanyagaur22
Created April 6, 2019 07:52
Show Gist options
  • Save Lavanyagaur22/92f585d3d4d0d5cbc4943cbcdfdca435 to your computer and use it in GitHub Desktop.
Save Lavanyagaur22/92f585d3d4d0d5cbc4943cbcdfdca435 to your computer and use it in GitHub Desktop.
private fun getOkhttpClient(context: Context): OkHttpClient? {
//Adding HttpLoggingInterceptor() to see the response body and the results.
val loggingInterceptor = HttpLoggingInterceptor()
loggingInterceptor.level = HttpLoggingInterceptor.Level.BODY
httpClient?.let {
return it
} ?: kotlin.run {
httpClient = OkHttpClient.Builder()
.addInterceptor(loggingInterceptor)
.addInterceptor(getConflictInterceptor(context)!!)
.build()
}
return httpClient
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment